建立一个Java窗体:
import javax.swing.*;
import java.awt.*;
public class frame
{
public static void mian(String arge[])
{
JFrame frame=new JFrame();
frame.setSize(400,350);
frame.setTitle("QQ登录");
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(3);
frame.setVisible(true);
}
}
1.this.setDefaultCloseOperation(0);// DO_NOTHING_ON_CLOSE,不执行任何操作。
2.this.setDefaultCloseOperation(1);//HIDE_ON_CLOSE,只隐藏界面,setVisible(false)。
3.this.setDefaultCloseOperation(2);//DISPOSE_ON_CLOSE,隐藏并释放窗体,dispose(),当最后一个窗口被释放后,则程序也随之运行结束。
4.this.setDefaultCloseOperation(3);//EXIT_ON_CLOSE,直接关闭应用程序,System.exit(0)。一个main函数对应一整个程序。