GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Adding and Removing JPanels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding and Removing JPanels" Watch "Adding and Removing JPanels" New topic
Author

Adding and Removing JPanels

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
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

Joined: Oct 29, 2001
Posts: 8914
    
    8

I would use a Card Layout.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Thanks, I never even considered it.
I've heard of it before, but never used it, and it works perfectly!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding and Removing JPanels