1

I'm trying to add a system tray icon to my Snow Leopard java application, which seems to work fairly well. Unfortunately, it seems like SWT does not align the systemtray icon with the top menubar, but instead aligns it with where my mouse clicked

(e.g. http://kobyleha.com/files/azureus_2_250.png instead of http://kobyleha.com/files/power_250.png ... I am borrowing the images since this site describes similar problems) It seems to have been a problem with SWT since 3.3. I'm wondering if there are any good workarounds available that someone could share?

Thanks!

mystro
  • 347
  • 3
  • 11
  • I don't know anything about SWT, but you could, for starters, set the y-coordinate of the popup to the osx menubar/tray height, which is - as far as I know - in most cases the same. – Tedil Aug 01 '10 at 09:52
  • Any idea how I can align with the x-coordinate of the icon? – mystro Aug 01 '10 at 19:56
  • Also, any way to keep the tray icon highlighted/selected while the menu is open? – mystro Aug 01 '10 at 20:33
  • Is there any reason you didn't choose java.awt.SystemTray in Java 6? It works fine for me on OSX. The only thing is that OSX makes all tray icons grayscale. – William Niu Aug 05 '10 at 21:41

1 Answers1

1

I know it's been long since you asked the question, but here's what works for me at least.

The vital line is item.setToolTip(tip); which will align the balloon to the tray item.

if (tray != null) {
    TrayItem item = new TrayItem(tray, SWT.NONE);
    image = display.getSystemImage(SWT.ICON_INFORMATION);
    item.setImage(image);
    tip.setText("Notification from a tray item");
    item.setToolTip(tip); // <<<-----
}
dandan78
  • 13,328
  • 13
  • 64
  • 78
Paaske
  • 4,345
  • 1
  • 21
  • 33