开发者

Global accelerator in java swing

开发者 https://www.devze.com 2023-03-13 09:41 出处:网络
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 ac

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消