我正在尝试使用SwingX中的MultiSplitPane和MultiSplitLayout。我知道如何使用方法parseModel使用MultiSplitLayout(请参阅http://today.java.net/pub/a/today/2006/03/23/multi-split-pane.html)。但是我不理解没有这种方法的机制。 如何重现这个?
String layoutDef =
"(COLUMN (ROW weight=1.0 left (COLUMN middle.top middle middle.bottom) right) bottom)";
MultiSplitLayout.Node modelRoot = MultiSplitLayout.parseModel(layoutDef);
答案 0 :(得分:7)
好的,我终于找到了答案。您应该首先查看图片以了解代码。
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");
了解代码背后逻辑的图片。 model og the layout http://today.java.net/images/2006/03/example3-diagram.gif