当前位置: 技术问答>java相关
如何实现点击JDialog右上方的X时,出现YESNO选择对话框,当点击YES时关闭JDialog,点击NO时不关闭
来源: 互联网 发布时间:2015-10-02
本文导语: 如何实现点击JDialog右上方的X时,出现YESNO选择对话框,当点击YES时关闭JDialog,点击NO时不关闭 | 增加这么个方法 protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (...
如何实现点击JDialog右上方的X时,出现YESNO选择对话框,当点击YES时关闭JDialog,点击NO时不关闭
|
增加这么个方法
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
int choose = JOptionPane.showConfirmDialog(this,"退出?","警告",JOptionPane.OK_CANCEL_OPTION);
if(choose==2){
return;
}else{
this.dispose();
}
}
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
int choose = JOptionPane.showConfirmDialog(this,"退出?","警告",JOptionPane.OK_CANCEL_OPTION);
if(choose==2){
return;
}else{
this.dispose();
}
}
|
super是不是调的靠前了?