Java桌面应用程序:按下热键时如何最大化托盘应用程序?
我需要编写一个程序,当最小化时,该程序位于系统托盘中,我将使用 Java 6 的 SystemTray API 来完成此任务。
当用户按下某个热键时,如何使该应用程序进入前台?
例如,应用程序正在运行但已最小化。 当用户按下 CTRL-SHIFT-Y 或其他键(或者像 Google 桌面的搜索一样,按 CTRL 两次)时,应用程序就会最大化。
I need to write a program that, when minimized, lives in the System Tray, and I'll use Java 6's SystemTray API to do that.
How can I make that application comes to the foreground when the user presses some hotkey?
For example, the app is running but minimized. When the user presses CTRL-SHIFT-Y or something (or, like Google Desktop's search, CTRL twice) and the application is maximized.
EDIT: I know about how to bring a Java window to the foreground. I'm asking more specifically about how to make a running Java app listen for a hotkey.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将需要求助于 JNI,请查看示例。
这是来自 Sun 论坛的另一个很好的示例。
You're going to need to resort to JNI, check out an example.
Here's another nice example from Sun's forums.
您可以使用以下 SWT 扩展库创建一个可以侦听热键的键盘挂钩 - http://feeling。 sourceforge.net/
请注意,这仅适用于 Windows(但这对您来说可能不是问题)。
You can use the following SWT extension library to create a keyboard hook that can listen for your hot key - http://feeling.sourceforge.net/
note, that this is windows only (but that may not be a problem for you).