import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.JFrame;
import javax.swing.JSplitPane;
public class Test extends JFrame{
public static void main(String[] args) {
new Test();
}
public Test(){
JSplitPane jsp=new JSplitPane();
this.add(jsp);
//设置分割线不可移动
jsp.setEnabled(false);
//设置监听器,获取当前窗口的大小,按比例分配
this.addComponentListener(new ComponentAdapter(){
public void componentResized(ComponentEvent e) {
jsp.setDividerLocation(0.67);
}
});
this.setLocation(200,200);
this.setSize(400,400);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
}