• Post Reply Bookmark Topic Watch Topic
  • New Topic

updating swing instantly  RSS feed

 
joseph mcgratton
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

i have a program with 2 jPanels. one contains a button, the other is initially blank. When the button is pressed, one of the jPanels has objects added to it. However, they dont show unless i resize the whole window. is there a way to update the panel with the objects without resizing?

thanks,

joseph.
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you can call the validate() method on the JPanel to make it redraw.
 
joseph mcgratton
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

thankyou for your reply. hopefully i can get it updating when it should

joseph.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternatively, you can call the panel's repaint() method. I don't know the difference between calling repaint() over calling validate(). you should look at the Javadocs for JPanel to find out for yourself.

Layne

p.s. For future reference, we have a GUI forum where such questions are discussed on a regular basis. You should consider posting related questions there as the experts on this particular portion of the Java API are more likely to be hanging out there.
[ March 02, 2005: Message edited by: Layne Lund ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Call validate() to tell the LayoutManager that you're done changing the container, and the contents should be re-laid out. Call repaint() if you just need some new bits on the screen.
 
joseph mcgratton
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

thankyou all for your help. i have got the problem solved a different way ( by accident). if i setText object eg "", the screen updates. Sorry for posting on the wrong forum. ill have to see what other forums are available. At the moment id only had this forum on my favorites (good helpful forum by the way ). Anyway, back another 2 hr slog to try and fix my loop problem.

Joseph.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!