package tlw.zbe.info.stratch;
import javax.swing.JFrame;
import javax.swing.JSplitPane;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentAdapter;
public class MainFrame extends JFrame {
public static void main(String[] args){
MainFrame f=new MainFrame();
}
private void myInit(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设定窗体关闭后自动退出进程
setSize(800,600);//设定窗体的默认尺寸
setVisible(true);//显示窗体
jSplitPane1.setDividerLocation(0.7);//设定分割面板的左右比例(这时候就生效了,如果放在setVisible(true)这据之前就不会有效果。)
/*****初始化事件***/
this.addComponentListener(new ComponentAdapter(){
public void componentResized(ComponentEvent e) {
jSplitPane1.setDividerLocation(0.7);
}
});
}
public MainFrame() {
try {
jbInit();
myInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER);
jSplitPane1.add(jPanel1, JSplitPane.LEFT);
jSplitPane1.add(jPanel2, JSplitPane.RIGHT);
}
JSplitPane jSplitPane1 = new JSplitPane();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
}
|