I need to ask if I want to close the window that is open. I made the following form, but in any of the options, it closes. I currently use this event option:
private void formWindowClosing(java.awt.event.WindowEvent evt) {
if (JOptionPane.showConfirmDialog(null, "Você deseja realmente fechar essa janela? Todas mensagens serão perdidas") != JOptionPane.YES_NO_OPTION)
{
this.setVisible(false);
}
}
This is a second form, I have the main, with the options and I have the second, where I ask if you really want to close. This is a JFrame.
Another detail is that in the message displayed there are 3 options: YES, NO and CANCEL. I just want the two options YES and NO.