How do I create a JSplitPane with oneTouchExpandable(true) but I want the panel to be collapsed when first displayed. I want to create a panel with collapsed panels on all 4 sides. Imagine a border layout with a panel in the middle and different panels on all four sides but collapsed. I have tried the following but doesn't work completly:
import java.awt.Dimension;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
public class SplitpaneTest {
public static void main(
String[] args) {
JFrame frame = new JFrame();
frame.setSize(new Dimension(600,600));
JPanel main = new JPanel();
main.setSize(new Dimension(500,500));
main.setMinimumSize(main.getPreferredSize());
JSplitPane spane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
new JTextArea("Top pane"),
main);
spane.setOneTouchExpandable(true);
spane.setResizeWeight(0.);
spane.setDividerLocation(0.0);
JSplitPane spane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
new JTextArea("Left pane"),spane);
spane2.setOneTouchExpandable(true);
spane2.setResizeWeight(.0);
spane2.setDividerLocation(.0);
JSplitPane spane3 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,spane2,
new JTextArea("Right pane"));
spane3.setOneTouchExpandable(true);
spane3.setResizeWeight(1.0);
spane3.setDividerLocation(0);
JSplitPane spane4 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,spane3,
new JTextArea("Bottom pane"));
spane4.setOneTouchExpandable(true);
spane4.setResizeWeight(1.0);
spane4.setDividerLocation(0);
}
}
Any ideas?