java - How to listen to keypress events in a jdialog container? -


i have jdialog contains many rows of textfields , submit button. know if it's possible add eventlistener container trigger submit button.

one convenient way bind enter action via root pane's setdefaultbutton() method. can use action in key binding, shown here.

jdialog d = new jdialog(…); action submit = new abstractaction("submit") {      @override     public void actionperformed(actionevent e) {         // handle submit     } }; private jbutton b = new jbutton(submit); … d.getrootpane().setdefaultbutton(b); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -