[英]Java desktop app: How to maximize tray application when hotkey pressed?
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. 我需要编写一个程序,当最小化时,它存在于系统托盘中,我将使用Java 6的SystemTray API来实现这一点。
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.
当用户按下CTRL-SHIFT-Y或其他东西(或者像Google桌面的搜索,CTRL两次)并且应用程序最大化时。
EDIT: I know about how to bring a Java window to the foreground . 编辑:我知道如何将Java窗口带到前台 。 I'm asking more specifically about
how to make a running Java app listen for a hotkey .
我更具体地询问如何使正在运行的Java应用程序监听热键 。
You're going to need to resort to JNI, check out an example . 你将需要求助于JNI,看一个例子 。
Here's another nice example from Sun's forums. 这是Sun的论坛的另一个很好的例子 。
You can use the following SWT extension library to create a keyboard hook that can listen for your hot key - http://feeling.sourceforge.net/ 您可以使用以下SWT扩展库来创建可以侦听热键的键盘钩子 - http://feeling.sourceforge.net/
note, that this is windows only (but that may not be a problem for you). 请注意,这只是Windows(但这对您来说可能不是问题)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.