This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 8839
    
    7

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
 
Similar Threads
CardLayout problem
JScrollPane doesn't work.
Questin on listeners
Image won't appear
Crack showing between polygons