• 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

JPanel validate()

 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a panel with some components. Initially I had set the layout to BoxLayout and when I removed components from the panel and call for myPanel.validate(), the panel get flushed away.
myPanel is inside the scrollPane.
Now I changed from BoxLayout to FlowLayout and changed teh size of the panel as below:

I am following the same procedure, after removing components, I am calling myPanel.validate();
But now, not everything gets flushed, but I could see some piece of info in the display. But they get cleared when I minimise the window and maximise it? How do I overcome this problem?
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried myPanel.repaint(); tehn calling myPanel.validate(); and now it works. Is this the correct way?
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gopu Akraju:
I tried myPanel.repaint(); tehn calling myPanel.validate(); and now it works. Is this the correct way?



I have seen many here use JPanel#revalidate() sometimes followed by JPanel#repaint(), but to be honest, I don't know what the canonical way to do this is.
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic