I am using windowClosing
to confirm before closing a particular JFrame.
Before closing I get a confirm dialog but the problem is it closes even if I click the NO button. Any help please?
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we)
{
String ObjButtons[] = {"Yes","No"};
int PromptResult = JOptionPane.showOptionDialog(null,
"Are you sure you want to exit?", "Online Examination System",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null,
ObjButtons,ObjButtons[1]);
if(PromptResult==0)
{
System.exit(0);
}
}
});