I am creating a Java applet, and I am trying to add a JFrame to it. I am calling:
add(new MyJFrameSubclass());
But when I launch the application, my JFrame
isn't shown until I resize the window.
I am creating a Java applet, and I am trying to add a JFrame to it. I am calling:
add(new MyJFrameSubclass());
But when I launch the application, my JFrame
isn't shown until I resize the window.
JFrame
and JApplet
are both top-level containers. Instead of trying to have both containers present at once, put your content in a lightweight container such as JPanel
; then add that JPanel
to either a JFrame
(for local use) or a JApplet
(for the browser). This example shows the approach.
This may be too elementary of a suggestion, but sticking in a validate()
or repaint()
can sometimes solve problems that seem complicated.