System Tray in Java
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> | Java 6 tray |
![]() |
![]() |
| SWT tray | JDIC tray |
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.
![]() |
Not implemented yet |
| Native tray> | Java 6 tray |
![]() |
![]() |
| SWT tray | JDIC tray |
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.
![]() |
![]() |
| Native tray> | Java 6 tray |
![]() |
![]() |
| SWT tray | 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.












Скриншоты под Ubuntu невероятны, сразу чувствуется рука мастера. Кто делал? (шучу, шучу)
А вообще — фигня вся эта ваша кроссплатформенность.
2007-05-18 at 2.59 pm
Спасибо тебе за скриншоты(email и аськи тебе все мало и мало :)).
2007-05-18 at 3.04 pm
Look at notifications too. In Gnome/Ubuntu, native notifications are big yellow thingys with rounded corners. JDK 6 gives odd-looking gray windows that look like my younger brother designed them.
2007-09-23 at 4.22 am