public App(){ //constructor
....
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
int select=JOptionPane.showConfirmDialog(null,"exit");
if(select==JOptionPane.YES_OPTION){
System.exit(0);
}
}
});
...
}
....
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
int select=JOptionPane.showConfirmDialog(null,"exit");
if(select==JOptionPane.YES_OPTION){
System.exit(0);
}
}
});
...
}
解决方案 »
- 关于字符串拆分的问题
- 关于jdk包中的java文件中的Exception类的构造函数问题???
- 垃圾回收器的考题
- asking for urgent help about my UI's problem
- 大家帮帮忙:在环境变量中怎么引入自定义类
- 自己在msn认识的人,被介绍到自己的公司后,那小子过河拆桥,真tmd的让生气和失望
- 求SWT界面设计方面的教程下载,分数不够在加!!
- 各位仁兄, 帮帮忙吧!
- 如何關閉一個窗口而不退出程序﹖
- 请问:java web start 是什么呢?
- 请问有没有办法取得ResultSet的行数?
- 关于Socket client与Socket Server间通信的问题!急!!!
{
System.exit(0);
}
这样就行了呀。如果点的是“取消”,那么返回值就不一样了,那不处理不就行了!
{
int select=JOptionPane.showConfirmDialog(null,"真的要退出吗?");
if(select==JOptionPane.YES_OPTION)
{ }
else
//这里怎么写?
}
---------------------------------------------------------------
else 这里就不用多写了,因为setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
这句就是你点了×以后,什么也不做。所以你在前面加上这句就可以了,
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);