How to make shortcut to invisible menu item in Java

后端 未结 1 1053
猫巷女王i
猫巷女王i 2021-01-24 21:35

I\'ve recently added a console dialog to my program to make catching bugs easier. This is currently accessible through a JMenuItem and has keyboard shortcut \'Ctrl+L\'.

1条回答
  •  [愿得一人]
    2021-01-24 22:23

    You should use the key bindings API: http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html

    Set accelerator key not to menu, but to the action behind the menu: getInputMap(WHEN_IN_FOCUSED_WINDOW).put( acceleratorKey, actionname);

    0 讨论(0)
提交回复
热议问题