Java problem - dispose()

  Dougie168 17:09 15 Apr 2006
Locked

help!!
I have a pop up window via a JOptionPane asking the user whether they really want to quit the existing system. As in the code, if the user does not choose the yes option then it should "dispose()" the pop up window but still keep the existing main window .. but when i run it it quits the whole system altogether. Any ideas?

this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent attemptClose)
{
int check = JOptionPane.showConfirmDialog(null,
"Are you sure you want to quit ?", null,
JOptionPane.YES_NO_OPTION);

if (check == JOptionPane.YES_OPTION)
System.exit(0);
else
dispose();
}
});

  Dougie168 17:17 15 Apr 2006

do i need a setVisible(true)..??

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

iMac Pro review

Illustrator of witty, relatable Instagram comics Julia Bernhard touches on our humble moments

iMac Pro review

Quelle est la meilleure application de podcast pour Android (2018) ?