Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Switching between panels -- CardLayout??

843805Nov 25 2006 — edited Nov 26 2006
I'm a newbie with Java and have bitten off more than I can chew. I have an application that has many panels switch I've been switching between using the following code (just included the snippet where I change panels):

JPanel test = new CustomerPanel();

this.removeAll();
this.setBounds(0,0,getWidth(), getHeight());

this.repaint();
this.add(test);

Thing is two of my panels are different colors and every time I switch I see the "other" one's color in the corner of the frame. I've tried a bunch of different things to fix it but since I don't have enough knowledge I'm looking for the needle in the haystack. I hate to re-do everything and create a CardLayout but it seems like I may need to. My problem is I looked at the Sun tutorial on CardLayouts and when I tried to play with it I couldn't get either panel to display in my designer (I'm using JBuilder 2005). Any ideas on either issue?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 24 2006
Added on Nov 25 2006
3 comments
924 views