Try to install this,
app.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE)
[Edited]
So your code will become something like this,
public static void main(String args[]) {
ButtonTest app = new ButtonTest();
app.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
int reply = JOptionPane.showConfirmDialog(null,
"Really Quit ?", "Quit", JOptionPane.YES_NO_OPTION);
if (reply == JOptionPane.YES_OPTION)
System.exit(0);
}
});
app.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
app.setSize(640, 480);
app.setVisible(true);
}
[Explanation]
, , . JFrame, Frame, . / . , , yes. , , . no, . , , DO_NOTHING_ON_CLOSE.
[]
Frame, JFrame , , . - JFrame, . , setDefaultCloseOperation (int). JFrame , Frame, setDefaultCloseOperation (WindowConstants.DO_NOTHING_ON_CLOSE).
: JFrame docs