Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding and Removing JPanels

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a JFrame, and these 2 objects:

Both Drawer1 and Drawer2 extend Drawer which extends JPanel.

First, I have to add drawer1:


Then later on, during runtime, the user might want to see drawer2 instead of drawer1.
I'm not sure how to correctly remove the drawer1 object and replace it with the drawer2 object.

Any thoughts? thanks.
 
Joe Ess
Bartender
Posts: 9302
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would use a Card Layout.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I never even considered it.
I've heard of it before, but never used it, and it works perfectly!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic