How to use MultiSplitLayout in SwingX?

I am trying to use MultiSplitPane and MultiSplitLayout from SwingX. I know how to use MultiSplitLayout using the parseModel method (see http://today.java.net/pub/a/today/2006/03/23/multi-split-pane.html ). But I do not 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); 
+4
source share
1 answer

Well, I finally found the answer myself. You must first look at the picture 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"); 

Picture to understand the logic of the code. model og the layout
(source: java.net )

+7
source

Source: https://habr.com/ru/post/1388363/


All Articles