Removing JPanels

I have an overall BorderLayout going, and I'm interchanging different JPanels in the NORTH position, depending on menu options the user chooses.

So I discovered that I need to remove the previous JPanel occupying the space before adding the new one.

So is there a way to find out which JPanel I currently have in the NORTH position?

[354 byte] By [KSteevesa] at [2007-11-27 7:07:00]
# 1

> I have an overall BorderLayout going, and I'm

> interchanging different JPanels in the NORTH

> position, depending on menu options the user chooses.

Why not just use the [url=http://java.sun.com/docs/books/tutorial/uiswing/layout/card.html]cardLayout[/url]. It think that it may be well suited for your purposes and easier than trying to reinvent the wheel.

> So is there a way to find out which JPanel I

> currently have in the NORTH position?

Of course, it's whichever panel you put in the North position. But more importantly, this smells of wrong design to me.

Message was edited by:

petes1234

petes1234a at 2007-7-12 18:58:19 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanks, I'll check out the card layout. I haven't learned about that at all in class. Thanks for the suggestion! =]
KSteevesa at 2007-7-12 18:58:19 > top of Java-index,Desktop,Core GUI APIs...
# 3
If you have to do what you are asking about, have you looked at the java docs? The answers are right there within the BorderLayout description. (hint, look [url= http://java.sun.com/j2se/1.5.0/docs/api/java/awt/BorderLayout.html#getLayoutComponent(java.lang.Object)]here[/url])
petes1234a at 2007-7-12 18:58:19 > top of Java-index,Desktop,Core GUI APIs...
# 4
I didn't find that when I looked earlier. Guess I didn't look thoroughly enough. But I got the Card Layout working anyways. It's so awesome! Thanks. =]
KSteevesa at 2007-7-12 18:58:19 > top of Java-index,Desktop,Core GUI APIs...
# 5
> I didn't find that when I looked earlier. Its a new method is JDK5.
camickra at 2007-7-12 18:58:19 > top of Java-index,Desktop,Core GUI APIs...