Why Enter Keypress Won’t Work On JButton Keypress

You wonder in your Java Swing application why after pressing the TAB key and the next button has focus, nothing happens when you press the ENTER key. Then you find out only the SPACE key works. The culprit here is the look and feel.

The ENTER key works only in the Windows look and feel. Other look and feel themes have the SPACE character as its ENTER representation. If you want to mimic the ENTER key instead of the SPACE key even though your look and feel theme is not Windows, here is how you do it.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *