so everytime i close my program obviously a window pops up asking if i want to close the app but im not sure what im suppose to write inside if NO is chosen.
right now everytime i press no the GUI closes.
ex.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
// Ask for confirmation before terminating the program.
int option = JOptionPane.showConfirmDialog(
ex,
"Are you sure you want to close the application?",
"Close Confirmation",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (option == JOptionPane.YES_OPTION) {
System.exit(0);
}
}
});
}
tried inserting a few different methods and codes I've found online.