• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JFrame won't repaint...

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
seems to work OK with this change

//scrollPane.revalidate();
//scrollPane.repaint();
frame.validate();
 
reply
    Bookmark Topic Watch Topic
  • New Topic