import javax.swing.*;
public class WorkOprFrame extends JFrame { //Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
}
public class WorkOprFrame extends JFrame { //Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
其次,System.exit(0);会导致很多该做的事情没有做,
比较
try {
return;/throw new Exception();/System.exit(0);
} finally {
System.out.prinln(".......");
}
就知道了推荐使用frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);具体的方法名和参数名可能会有出入,
然后将System.exit(0);--〉dispose();