So basically, I have a JFrame, which originally contains panel A. After a few interactions, I want to remove this panel and add a new panel, say B. The problem is B won't show up until I resize the window. I even trying calling repaint(), but it doesn't seem to help. Can anyone explain what's going on? and how to fix the problem?
Thanks
3 Replies - 4731 Views - Last Post: 29 September 2010 - 05:07 PM
#1
JPanel won't show up until I resize the window (JFrame) manually.
Posted 29 September 2010 - 04:27 PM
Replies To: JPanel won't show up until I resize the window (JFrame) manually.
#2
Re: JPanel won't show up until I resize the window (JFrame) manually.
Posted 29 September 2010 - 04:35 PM
I believe calling the validate() method in the JFrame will fix this problem.
#3
Re: JPanel won't show up until I resize the window (JFrame) manually.
Posted 29 September 2010 - 04:55 PM
#4
Re: JPanel won't show up until I resize the window (JFrame) manually.
Posted 29 September 2010 - 05:07 PM
Yep. validate() tells a Top-level component to "readjust" the screen if it changes while setVisible() is true. For components like JPanel or JComponent, you use revalidate() for the same purpose.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote








|