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.

Windows Native Windows Java
Native tray Java 6 tray
   
Windows SWT Windows JDIC
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.

Mac Native Not implemented yet
Native tray Java 6 tray
   
Mac SWT Mac JDIC
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.

linux native tray linux java tray
Native tray Java 6 tray
   
linux swt tray linux jdic 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.

This entry was posted on Friday, May 18th, 2007 at 1.52 pm and is filed under development, java. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

3 Responses to “System Tray in Java”

  • Dmytro Shteflyuk says:

    Скриншоты под Ubuntu невероятны, сразу чувствуется рука мастера. Кто делал? (шучу, шучу)

    А вообще — фигня вся эта ваша кроссплатформенность.

  • erka says:

    Спасибо тебе за скриншоты(email и аськи тебе все мало и мало :)).

  • Cay Horstmann says:

    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.

Leave a Reply