I am using the following code to create a very simple JFrame
, but for some reason it doesn\'t show any components, just a blank frame. Why is this happening? I
You have to move frame.setVisible(true);
to the end of the method; the visibility must be set to true after you have added the components.
Alternatively, you can add the following to the end of your method:
frame.revalidate();
frame.repaint();
to revalidate and repaint the frame with the newly added components although I recommend the former method.