Dan*_* D. 14
基本上,你几乎是正确的.有些事情没有正确拼凑而成.
首先删除你的WindowClosing方法(window不是Window),然后用addWindowListener(new WindowAdapter());下面的代码替换你
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
int confirmed = JOptionPane.showConfirmDialog(null,
"Are you sure you want to exit the program?", "Exit Program Message Box",
JOptionPane.YES_NO_OPTION);
if (confirmed == JOptionPane.YES_OPTION) {
dispose();
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15100 次 |
| 最近记录: |