Several days ago I talked with my friend about a problem with using system tray in java. He develops a desktop application and needs a crossplatform (Microsoft Windows, Mac OS X and Linux) solution for system tray. Of course, you could say: “What the problem? Just use java 6”. Yep, you are right but we have one big problem — jdk 1.6 has not been implemented yet for Mac OS X. I hope when Leopard will be released I would be able to use it.

If you would look into this problem you would find two solutions. The first one is an SWT, and the second one — JDIC. These libraries have a API and native implementations for system tray. I have never worked with tray early and decided to try. I have developed small classes and run them on Windows, Mac OS X and Linux Ubuntu (with Gnome as Desktop Manager). So, here are my results.

First OS is Microsoft Windows XP.

Native tray
Native tray
Windows Java
Windows Java
Windows SWT
Windows SWT
Windows JDIC
Windows JDIC

As you could see Java 6 and SWT have native look and feel. JDIC has a problem with popup menu position.

Second one is Mac OS X.

Mac Native
Mac Native
Mac SWT
Mac SWT
Mac JDIC
Mac JDIC
SWT has the same problem on Mac OS X as JDIC on Windows. Popup menu position is wrong. JDIC shows menu without any defects, but it has problems with separator. I can not see it at all.

Third one is Linux.

linux native tray
linux native tray
linux java tray
linux java tray
linux SWT tray
linux SWT tray
linux JDIC tray
linux JDIC tray

Java 6 has a big problem with look and feel at Linux. That is really a bad news. Another problem is an icon size: Ubuntu has not resized my one (which is 200×152). All my examples have wrong popup menu position.

So, all implementations have problems. Enjoy it!

Download the source.