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.
Instead of creating multiple posts why don't you try reading your [url http://forum.java.sun.com/thread.jsp?thread=561186&forum=57&message=2759482]original post so people don't waste time answering questions that have already been answered.