3 Replies - 7026 Views - Last Post: 29 September 2010 - 05:07 PM Rate Topic: -----

#1 oo123oo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 29-September 10

JPanel won't show up until I resize the window (JFrame) manually.

Posted 29 September 2010 - 04:27 PM

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
Is This A Good Question/Topic? 0
  • +

Replies To: JPanel won't show up until I resize the window (JFrame) manually.

#2 H3R3T1C  Icon User is offline

  • Android Expert
  • member icon

Reputation: 277
  • View blog
  • Posts: 757
  • Joined: 30-March 07

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.
Was This Post Helpful? 3
  • +
  • -

#3 oo123oo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 29-September 10

Re: JPanel won't show up until I resize the window (JFrame) manually.

Posted 29 September 2010 - 04:55 PM

View PostH3R3T1C, on 29 September 2010 - 03:35 PM, said:

I believe calling the validate() method in the JFrame will fix this problem.



It worked!! thanks!!
Was This Post Helpful? 0
  • +
  • -

#4 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2872
  • View blog
  • Posts: 11,031
  • Joined: 15-July 08

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.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1