This discussion is archived
4 Replies Latest reply: Oct 8, 2004 9:05 PM by 3004 RSS

Add and remove  panel below a main top pane without affecting the top pane

3004 Newbie
Currently Being Moderated
I am trying to write a Swing based application with a main frame containing 2 panels:
- a main top panel (always visible)
- a bottom panel that comes and goes.

When the user clicks on a button named "Show Cache", I want the bottom panel to show up below the main panel. When the user clicks on another button "Hide Cache", I want the new panel to disappear.
Whether the bottom panel is visible or not, I do not want the appearance of the top panel to change.

I have tried many things but I can't get it to work properly:

1st problem: typically, when I click on "Show Cache", the frame does not get larger and the bottom panels fills the space inside the frame, leaving a little room above for the main panel.

2nd problem: Now, if I enlarge the window by dragging down its south border, everything looks fine. However, when I click "HIde Cache", the bottom pane disappears as expected, but the freed space is filled by the top main pane, which becomes much larger than at the beginning. I want the freed space to vanish.

I have tried setVisible(true/false), I have tried setSize on the panel to resize it, I have tried add and remove on the new panel... Nothing works fine. Each time the top pane is affected by the creation of the bottom pane or by its disappearance.

Thanks in advance for your help.

hc