求一段代码 当退出程序时,单击窗提右上角的关闭按钮,回提示是否推出程序.若选"是"则退出程序,若选"否"则不退出承袭. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 JFrame首先设置setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);然后该JFrame添加WindowListeneraddWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) { if(JOptionPane.showConfirmDialog(e.getWindow(),"Are you sure to exit?","Confirm",JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION){ System.exit(0); } else{ return; } } }); Java Sing Entry函数问题 ItemListener 没反应???? 请问 “public static 方法”的 public 有何意义 急。。有效回答马上给分 我编译的时候出现的一个问题? 请教一个有关ClassLoader问题 谁有关于java的DOM的例子?? 问一个java的安装问题。 谁有JBOSS的全套文档,如能提供必给分?TO pengchy(龙在天) 求助httpServer的应答码问题 树的问题 网络编程的小问题,望指教
然后该JFrame添加WindowListener
addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) {
if(JOptionPane.showConfirmDialog(e.getWindow(),"Are you sure to exit?","Confirm",JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION){
System.exit(0);
}
else{
return;
}
}
});