frame_ref = new Frame("Login");
mainPanel_ref = new Panel();
buttonPanel_ref = new Panel();
grid_ref = new GridLayout(4,2);
frame_ref.setSize(300,120);
frame_ref.setVisible(true);
email_ref = new TextField();
password_ref = new JPasswordField();
mainPanel_ref.setLayout(grid_ref);
mainPanel_ref.add(new Label("E-Mail"));
mainPanel_ref.add(email_ref);
mainPanel_ref.add(new Label("Passwort"));
mainPanel_ref.add(password_ref);
mainPanel_ref.add(submitLogin_ref);
mainPanel_ref.add(fehlerMeldung_ref);
frame_ref.add(mainPanel_ref);
I set up a view in Java like above. The window is complete empty, but after I drag and drop its size, all the elements appear. Does somebody know how to fix this?
Call
frame_ref.setVisible(true);afterframe_ref.add(mainPanel_ref);.What happens here is: You show frame by calling
frame_ref.setVisible(true);and then add elements in it. So you get an empty frame. Afterwards when you drag or resize it gets repainted and you can see elements.