6

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.

Community
  • 1
  • 1
David Koelle
  • 20,726
  • 23
  • 93
  • 130
  • I searched for hours for a solution to this problem. Found nothing which doesn't involve JNI. It is very sad that Sun (or now, Oracle) don't care about Java on the desktop. – ivan_ivanovich_ivanoff Jun 13 '09 at 18:20

2 Answers2

3

You're going to need to resort to JNI, check out an example.

Here's another nice example from Sun's forums.

Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
0

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).

Peter Smith
  • 753
  • 6
  • 7