In my Swing application, while i am closing the window one popup(confirmation box) is coming.
JOptionPane.showConfirmDialog(dialog, "Do You really want to exit the application", "choose", JOptionPane.YES_NO_OPTION)
There appears an alert message like " Do You really want to exit the application" , Then move the cursor to "NO" and press " Enter " key with the keyboard
It is working fine for Mouse click but not working for EnterKey
Actual Result : It is closing the application
Expected Result : It should suspend the action
Any one can help on this.
1 Replies - 4855 Views - Last Post: 02 January 2006 - 11:16 AM
Replies To: Improper behavior of exit button using a Enter Key
Re: Improper behavior of exit button using a Enter Key
Posted 02 January 2006 - 11:16 AM
I had a similar problem in my app. I had a YES/NO dialog and when I used the Tab key to move the focus to the No button and hit Enter, it would click the Yes button instead. I found out that it has to do with which button has the default focus. I believe the default focused button is different, depending on which L&F you are using. One way to make sure that the selected button follows the focus is to specify it at the beginning of your program with the following:
Page 1 of 1