SWT SystemTray in OSX

吃可爱长大的小学妹 提交于 2019-12-24 07:26:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!