File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JFrame won't repaint... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame won Watch "JFrame won New topic
Author

JFrame won't repaint...

Matthew Alesi
Ranch Hand

Joined: Sep 13, 2006
Posts: 38
This seems like an elementary issue, but it's tarnishing my application. When my GUI first shows, it's a toolbar with an empty JScrollPane below it, and you're supposed to cllick Open in the toolbar, and then stuff shows up below. But when I set up the stuff below and call setVisible(true) on the scrollpane to display all the contents, nothing shows up. The only way to make it display is to resize the frame.

Nonetheless, whenever I make any subsequent changes, the GUI updates itself properly.

Why is this happening, and how can I get my GUI to repaint for sure without an ugly (unnecessary) resize?

This is due soon. Thanks everybody!


-Matt
Current CS undergrad
SCJP 5.0
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if you add components to the scrollPane you will need (after adding)
scrollPane.revalidate();
scrollPane.repaint();//sometimes required, sometimes not

if this is not the problem, post a sample program that displays the behavior.

(be a good idea for you to delete your duplicate post)
Matthew Alesi
Ranch Hand

Joined: Sep 13, 2006
Posts: 38
Here's a small program that replicates the problem. You have a button on the top that sets the text of a label on a panel within the scroll pane. However, the window doesn't update.



I hope this helps!
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
seems to work OK with this change

//scrollPane.revalidate();
//scrollPane.repaint();
frame.validate();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame won't repaint...
 
Similar Threads
add(lable) doesnt show till i resize
Favorite Features
Problem about adding component to Panel
design advice
How to force the repainting of a component