tags:

views:

785

answers:

2

I have a JQueryDialog with a text field, an OK button and a cancel button.

I want to be able to hit the enter key after filling in the text fields and have it do the same action as when I click the OK button.

+8  A: 

In your dialog, call getRootPane().setDefaultButton(okButton).

Jason Day
A: 

The code is almost correct. I would change the if comparison and use the correct method as noted below.

if (KeyEvent.VK_ENTER == event.getKeyCode()) {
                yourButton.doClick();
            }
John Yeary