I have made accelerators in my java gui by using setAccelerator(), and they work unless something with the s开发者_如何学Goame key binding is in focus. Is there a way to enable them globally so the action is triggered no matter what if the window has focus?
jmi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK))
Take a look at Global Event Dispatching. You should be able to use a KeyEventDispatcher to intercept any key event to do your custom processing.
精彩评论