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.
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.
Third one is Linux.
linux native tray
linux java tray
linux SWT 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.