这是我的代码:
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
int a = JOptionPane.showConfirmDialog(null,
"Are you sure you want to exit the program?", "Exit Program ",
JOptionPane.YES_NO_OPTION);
System.out.println(a);
if(a==JOptionPane.OK_OPTION){
dispose();
}
}});
问题是或者a==OK_OPTION
框架a==CANCEL_OPTION
将关闭。
为什么?