Hello All,
I have a Java program which is using a JOptionPane in it.
eg. Are you sure u want to close the application?
Yes No
When I click with the mouse on the No button it works correctly but if I select the No button using the TAB key and press enter key the application still closes.
Can anyone tell me whats going wrong
public class WindowHandler extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
int OptionChoosed=JOptionPane.showConfirmDialog(null, "<html><p><font color=\"#FF8C00\" " +
"size=\"4\" face=\"Book Antiqua\">Close the Application ?"+
"</font></p></html>" ,"Warning",JOptionPane.YES_NO_OPTION);
System.out.println(OptionChoosed);
if (OptionChoosed==0)
{
try
{
if (databaseInformationModel != null)
{ // may have failed to be initialized for some reason
JOptionPane.showMessageDialog(null,"ABCD" +OptionChoosed,"null",JOptionPane.WARNING_MESSAGE); //just a debugger
databaseInformationModel.close(); // we want to shut it down and compact it before exiting
System.exit(0);
}
}
catch (Exception e1){e1.printStackTrace();}
}
else if (OptionChoosed==1)
{
System.out.println(OptionChoosed+"Do nothing");
}
JOptionPane.showMessageDialog(null,"OUT" +OptionChoosed,"null",JOptionPane.WARNING_MESSAGE); //just a debugger
}//windowClosing
}//WindowHandler
I need the button to react to the mouse listener as well as the key listener depending on the users choice