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
# 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])