• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel validate()

 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I tried myPanel.repaint(); tehn calling myPanel.validate(); and now it works. Is this the correct way?
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!