简体   繁体   English

Java应用程序中的可自定义快捷方式

[英]Customizable Shortcuts in Java Application

I would like to include customizable keyboard shortcuts in my Java application (the user can change them). 我想在我的Java应用程序中包含可自定义的键盘快捷键(用户可以更改它们)。 Since this is not very unusual request, I was wondering if there exists a library/project that could help me achieve my goal. 由于这不是一个非常不寻常的请求,我想知道是否存在可以帮助我实现目标的库/项目。

Unfortunately I was not able to find anything useful on Google. 很遗憾,我无法在Google上找到任何有用的内容。

Thank you, aZen 谢谢,aZen


Ended up building my own shortcut manager from scratch. 从头开始构建我自己的快捷方式管理器。 This took around 20h. 这花了大约20小时。

Shortcuts may be specified as accelerators in instances of Action . 可以在Action实例中将快捷方式指定为加速器。 Less flexibly, shortcuts may be represented by KeyEvent instances obtained via KeyListener . 不太灵活,快捷方式可以通过KeyListener获得的KeyEvent实例表示。 Either may be stored in java.util.Preferences or javax.jnlp.BasicService , as suggested here . 要么可以存储在java.util.Preferencesjavax.jnlp.BasicService ,如建议在这里

I'm unaware of a general purpose library, but this game offers an RCKeys dialog to remap keys. 我不知道通用库,但是这个游戏提供了一个RCKeys对话框来重新映射键。 It includes the essential functionality to preclude duplicates. 它包括排除重复的基本功能。

图片

I don't know of any libraries, but if your stuck you should take a look at KeyboardFocusManager & KeyboardEventDispatcher or KeyboardEventPostProcessor . 我不知道任何库,但如果你卡住了你应该看一下KeyboardFocusManagerKeyboardEventDispatcherKeyboardEventPostProcessor

These will at least give you access to the system level key events 这些至少可以让您访问系统级别的关键事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM