问题
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!
回答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); // <<<-----
}
来源:https://stackoverflow.com/questions/3381178/swt-systemtray-in-osx