简体   繁体   English

OSX中的SWT SystemTray

[英]SWT SystemTray in OSX

I'm trying to add a system tray icon to my Snow Leopard java application, which seems to work fairly well. 我正在尝试将系统任务栏图标添加到Snow Leopard Java应用程序中,该图标似乎运行良好。 Unfortunately, it seems like SWT does not align the systemtray icon with the top menubar, but instead aligns it with where my mouse clicked 不幸的是,SWT似乎没有将系统托盘图标与顶部菜单栏对齐,而是将其与鼠标单击的位置对齐

(eg 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. (例如, http : //kobyleha.com/files/azureus_2_250.png而不是http://kobyleha.com/files/power_250.png ...由于该站点描述了类似的问题,我借用了图像)似乎已经从3.3开始就存在SWT问题。 I'm wondering if there are any good workarounds available that someone could share? 我想知道是否有人可以分享任何好的解决方法?

Thanks! 谢谢!

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); 重要的行是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); // <<<-----
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM