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.

I am not really sure if there is a concrete way to do this. In my case, what I did was create a dirty hack to prolong a tooltip’s visible delay by making use of the ToolTipManager setDismissDelay() method.

I figure nobody would look at a tooltip for a whole 10 minutes so that it what I set as default value. By setting the setDismissDelay() method to 10 minutes of equivalent milliseconds in the component’s mouseEntered event, the tooltip will always show itself until the mouse cursor is off the component’s area when mouseExited is invoked.

As I said, it may not be the accurate way to stop the delay but it works! 😉

Related Posts Plugin for WordPress, Blogger...