• Post Reply Bookmark Topic Watch Topic
  • New Topic

Panel appears only when resizing JFrame.  RSS feed

 
Punit Jain
Ranch Hand
Posts: 1066
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello i have a layout in which i have four buttons in the west side of my border layout, and when i click on any of button my panel of center layout gets change..
(ie, if i click home, the center of border layout get home panel, when i click register the center of border layout get register panel and so on....)
but the problem is the are appearing only when i m resizing my frame, i mean maximizing my frame..
here is my code:




CustomerLayout.java


Home.java

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any time you change components when the parent is visible, you need to add the indicated lines

[container].add(someComponent);
[container].revalidate();//for swing//<----------------or next line (for awt), not both
[container].validate();//for awt
[container].repaint();//not always rerquired, safer to include//<------------------

from your description, the panel that changes would be more ideally suited to a CardLayout,
which would make revalidate()/repaint() unnecessary
 
Punit Jain
Ranch Hand
Posts: 1066
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's working...thank you....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!