I'm trying to use MultiSplitPane and MultiSplitLayout from SwingX. I know how to use MultiSplitLayout with the method parseModel (see http://today.java.net/pub/a/today/2006/03/23/multi-split-pane.html). But I don't understand the mechanism without this method. How to reproduce this?
String layoutDef =
"(COLUMN (ROW weight=1.0 left (COLUMN middle.top middle middle.bottom) right) bottom)";
MultiSplitLayout.Node modelRoot = MultiSplitLayout.parseModel(layoutDef);
Ok, I finally found the answer myself. You should look at the picture first to understand the code.
Split column1 = new Split();
column1.setRowLayout(false);
Split row = new Split();
Split column2 = new Split();
column2.setRowLayout(false);
column2.setChildren(new Leaf("middle.top"), new Divider(), new Leaf(
"middle"), new Divider(), new Leaf("middle.bottom"));
row.setChildren(new Leaf("left"), new Divider(), column2,
new Divider(), new Leaf("right"));
column1.setChildren(row, new Divider(), new Leaf("bottom"));
// Once the layout is done, the code is easy
JXMultiSplitPane msp = new JXMultiSplitPane();
MultiSplitLayout layout = new MultiSplitLayout(column1);
msp.setLayout(layout);
msp.add(new JButton("bottom"), "bottom");
msp.add(new JButton("left"), "left");
msp.add(new JButton("right"), "right");
msp.add(new JButton("middle.bottom"), "middle.bottom");
msp.add(new JButton("middle"), "middle");
msp.add(new JButton("middle.top"), "middle.top");
The picture to understand the logic behind the code.
(source: java.net)