Hi i have a jFrame and I wish to ask the user whether he is sure to close the jframe when the close button is clicked:
this.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent windowEvent) {
Main ma = new Main();
Object[] options = {"Yes", "NO"};
int selectedOption = JOptionPane.showOptionDialog(ma, "Are you sure you want to close the system?", "Warning",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
if (selectedOption == JOptionPane.YES_OPTION) {
System.exit(0);
}
else
{
}
}
});
How shall i undo the close operation when he selects the 'NO' button from the jpanel popup?