java - Spacebar shortcut for JMenuItem -
i'm working on menu-driven java swing application. has 4 5 menus have 4 or more menu items. defined shortcuts menu item using jmenubar#setkeyaccelerator(keystroke key)
. when define spacebar
shortcut , press space
, fires event first jmenuitem
or selected menu item. here code snippet:
jmenuitem item = new jmenuitem("do something"); item.setkeyaccelerator(keystroke.getkeystroke(keyevent.vk_space, 0));
how add spacebar menuitem works fine.
i spot problem, added toolbar having button , button automatically focused, that's why when press space, press button on jtoolbar
Comments
Post a Comment