f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent w){
int num = JOptionPane.showConfirmDialog(f,"确定要退出吗?","提示",JOptionPane.OK_CANCEL_OPTION);
if(num == JOptionPane.YES_OPTION){
System.exit(0);
}else{
return;
}
}
});
这个是我的代码..不管用..不管确定还是取消都是退出程序..麻烦高手帮帮菜鸟...谢谢..
public void windowClosing(WindowEvent w){
int num = JOptionPane.showConfirmDialog(f,"确定要退出吗?","提示",JOptionPane.OK_CANCEL_OPTION);
if(num == JOptionPane.YES_OPTION){
System.exit(0);
}else{
return;
}
}
});
这个是我的代码..不管用..不管确定还是取消都是退出程序..麻烦高手帮帮菜鸟...谢谢..
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
把这行注释掉