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

Xiaomi Mi Mix 2 review

What went wrong at the Designs of the Year 2017

iPhone X news: Release date, price, new features & specs

Comment regarder des séries et talk-shows américains en France ?