Hi,
For a JFrame, we can set the default Button as:
frame.getRootPane().setDefaultButton(button);
This will automatically invoke the click event of the button when Enter key is pressed. I have a JButton inside a JPanel, and I want to set the default button to this JButton which is there inside a JPanel. How can I do it?
If I add the KeyListener, then, the default focus (the black colored border) is not visible (eventhough the button's click event happens when Enter key is pressed). How can I have both, the Enter key support as well as the default focus for the JButton which will be inside the JPanel.
Thank you.