使用JSplitPane

1、创建和初始化

//Create a split pane with the two scroll panes in it.
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                           listScrollPane, pictureScrollPane);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(150);

//Provide minimum sizes for the two components in the split pane
Dimension minimumSize = new Dimension(100, 50);
listScrollPane.setMinimumSize(minimumSize);
pictureScrollPane.setMinimumSize(minimumSize);

2、设置组件

setLeftComponent
setRightComponent
setTopComponent
setBottomComponent

3、定位分隔条DIVIDER以及限制分隔条范围

默认情况下splitPane的首选尺寸和分隔条的位置由放置其中组件的决定,以保证组件都处于其首选尺寸。

你可能感兴趣的:(split)