JFrame jf;
Container container;
void init(){
//初始化框架
jf = new JFrame();
jf.setSize(400, 500);
//将容器放在框架上 获得容纳面板
container = jf.getContentPane();
//做其他事情
//设置窗口可视化
jf.setVisible(true);
//设置点击'x'关闭窗口程序
jf.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
标签:初始化,JFrame,窗口,编程,new,container,jf
From: https://www.cnblogs.com/geeklee/p/17285870.html