aspose file tools
The moose likes Swing / AWT / SWT and the fly likes JFrame doesn't display components at first Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "JFrame doesn Watch "JFrame doesn New topic
Author

JFrame doesn't display components at first

Jos� Alberto Mu�iz Navarro
Ranch Hand

Joined: Oct 27, 2003
Posts: 33
Good day. I have an application to write and read a file. However, when the JFrame displays, it is SOMETIMES just an empty JFrame. If you resize it or move it, then the components (Some Checkboxes and a JButton) appear.
I have no idea about what it could be. Could you please help me?
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Jose,
It looks fine to me. You may want to pack() the contents of the frame before you display it. That may help.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Jos� Alberto Mu�iz Navarro
Ranch Hand

Joined: Oct 27, 2003
Posts: 33
It didn't work :S It still does the same thing. I repeat, only the JFrame appears but it is blank. Nothing appears inside. Just as if you had displayed a blank frame. However, if I resize the window (even to make it smaller... or making it bigger and then adjusting it to the previous size), all the components appear, although they previously had had the space to display them.
It's not a matter of the components not having enough space (I think). Otherwise the pack() would have solved it, am I wrong?
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Move the call to setSize down to the bottom of the constructor:

setSize or pack create the peer and signal the layout manager to layout its components. You want to call one of them after you add you components to the content pane. Otherwise you will have to validate the layout.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JFrame doesn't display components at first
 
Similar Threads
adding a picture
listener dead?
JCheckBox?
adding a picture
problem with listener