WindowAdapter.windowClosing() close window anyway
Cheer,
I have a few lines of code that used to work with TabbedPane/JPanel but we have moved to TreeMenu / CardLayout recently and then this windowClosing() no longer works. (sorry but this is the only thing I can think of as the major change from old version to this version)
Here is the code
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
doClose();
}
public void doClose() {
int i = JOptionPane.showConfirmDialog(this, "Do you want to save changes before closing?");
if ( i < 0 || i > 1 ) // user closed this popup,
// or clicked on Cancel
{
return;
}
if ( i == 0 )// YES
doSave();
System.exit(0);// proceed to terminate
}
I expect (and it did work before) once user cancels this activity, the program stay alive. But for some unknown reason, the window disappears but the process is still running (can see it in window task manager). It looks like doing a dispose() but that is not what I want.
Can anyone suggest some clue?
Thank you so much in advance.
Gigi

