TrayIcon in JDK 1.6
Has anyone else been playing with the SystemTray and TrayIcon in JDK 1.6? I've been messing around with it some and have run into a few shortcomings, and was wondering if anyone has found ways around them.
It looks like the API allows us to do three things with the TrayIcon: show a PopupMenu (but not a JPopupMenu <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6440297>), display a message (which has some display problems under Linux <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6440297>), and show a tooltip. Oh, and handle mouse events, which is coming in handy.
So these are pretty limited options. The message display is particularly problematic--there's no way that I can find to control how long the messages are displayed, or to tell if any mouse interaction is happening with the message windows or with the TrayIcon itself. For that matter, I can't even tell if there's currently a message showing or not. So unless we can get some more fine-grained control into the API, I think that I'm going to have to resort to other methods.
Now, the MouseListener combined with a straight JDialog (with setUndecorated(true)) turns out to be a pretty good workaround for me. I can get the screen coordinates from the MouseEvent and then add in any components I want, including buttons, hyperlinked text, etc. I will have to jump through serious hoops in order to make sure that it displays in the correct place and doesn't try to go off the side of the screen or anything. And I'll have to hand-code a thread timer to get it to disappear on its own. But in general it should work for handling user clicks.
This doesn't handle application-generated messages, though. The TrayIcon and SystemTray don't seem to have a getLocationOnScreen() method, so I don't know where to put the JDialog. I suppose that I could add in a hackalicious bit that saves the last MouseEvent and hope that I get some mouse interaction before I need to display any messages, but that seems like a very sub-optimal solution.
So is there something that I'm missing here? Or is the functionality of the TrayIcon actually as limited as it seems?

