import javax.swing.border.TitledBorder;
import java.awt.*;
/**
* Created by IBM on 2017/8/17.
*/
public class JSplitPaneDemo extends JFrame {
public static void main(String args[]) {
try {
JSplitPaneDemo frame = new JSplitPaneDemo();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
public JSplitPaneDemo(){
final JSplitPane splitPane = new JSplitPane();// 創建分割面版對象
splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);// 設置爲水平分割
splitPane.setDividerLocation(755);// 設置面版默認的分割位置
splitPane.setDividerSize(10);// 設置分割條的寬度
splitPane.setOneTouchExpandable(true);// 設置爲支持快速展開/摺疊分割條
splitPane.setBorder(new TitledBorder(null, "",
TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION, null, null));// 設置面版的邊框
getContentPane().add(splitPane, BorderLayout.CENTER);// 將分割面版添加到上級容器中
}
}
運行效果: