ないのベストプラクティスではなく、好ましい方法、唯一の現在のJVMインスタンスを閉じて、非常にシンプルにするために、
1)Top-LevelContainer#setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
2)WindowListener
WindowListener exitListener = new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
int confirm = JOptionPane.showOptionDialog(null,
"Are You Sure to Close Application?", "Exit Confirmation",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
null, null, null);
if (confirm == JOptionPane.YES_OPTION) {
Top-LevelContainer#setVisible(false);
// clean-up everything
// on error display JOptionPane with error mgs but from
// another JVM instance, e.g.jar file, see add 3.)
System.exit(1); //in some cases not works System.exit(0);
}
}
3を追加)hereはのために休みです別のJVMインスタンスからエラーメッセージを表示する方法
私の質問あなたが本当に知りたいことは何ですか、v奇妙な質問 – mKorbel