java 之JSplitPane

import javax.swing.*;
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);// 将分割面版添加到上级容器中
    }

}


运行效果:

java 之JSplitPane