In Java an application can send a notification to the system tray, by using TrayIcon.displayMessage(). Unfortunately, in KDE this produced a visually horrible box that looks nothing like the nice notification system.
It turns out to be rather difficult to change this behaviour. One needs to mess with the Java AWT internals by subclassing the XToolkit and using the resulting JoxyToolkit instead of XToolkit. In JoxyToolkit the method for producing a notification was changed to use the notify-send
program. This produces a nice notification that also is put in the notification list.
Unfortunately this interferes with having an icon in the system tray, so the icon firing the notification will actually be unvisible. (That doesn't matter for notify-send
, but in Java a notification always originates of one of the tray icons.)
Compiling now can be a bit more difficult than usual, because Eclipse (our IDE), and possibly other IDE's too, complain about the fact that we are subclassing a class that is a Java internal. Furthermore, when starting a program with Joxy, next to the usual Joxy options, the option -Dawt.toolkit=joxy.kde.JoxyToolkit
needs to be given.
We cannot imagine that this all is bug-free, so please don't use this at the moment, unless you really want it :-)