• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

updating swing instantly

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,

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

joseph.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic