Java – Effective way to make a system tray application

c++desktop-applicationjavasystem-tray

This is my first post on Stack Overflow and I'm just wondering on the options of making a system tray application. The application would run primary from the system tray while still operating, and could be brought up into a window when clicked on. It is also needed to have some support for global keystroke tracking, to bring up a window.

I'm curious on what options I have available to me, as I'm sure that there are many ways to do this. I'm most familiar with with Java though I have some experience with C++. I'm willing to explore other languages if they have some definite perks to them, though it would be nice to work with what I know in a way.

Thank you

Best Solution

Java 6 has new functionality which allows for the creation of applications which use the system tray.

The New System Tray Functionality in Java SE 6 article goes into the details, and provides some sample code as well.

The newly added SystemTray and TrayIcon classes of the java.awt package can be used to add icons to the system tray. The icons can respond to mouse clicks and use pop up menus as well. However, this new functionality is a part of AWT, so it doesn't do a very good job integrating with Swing components.

Here's an example of a little clock that shows up in the system tray which was made using the SystemTray and TrayIcon classes in Java 6:

System tray clock application in Java
(source: coobird.net)