I want to create a form in which if the User presses Enter the form is submitted. The problem is that this form has many components each having its own event handlers.
I wanted to create a KeyListener for the entire panel but the event gets consumed by the components of the panel, and does not reach the panel.
Currently I have added a KeyListener, to each of the components, listening the Enter key. Is there a better way out of this?
Thanks.
use
getRootPane().setDefaultButton(myButton);KeyListener isn’t designated for Swing JComponents, you have look as to use KeyBindings
SSCCE code
* code *