SWT TrayItem location

无人久伴 提交于 2019-12-11 04:46:26

问题


I use SWT + JFace and want to show my application window near the tray icon, like ToolTip.

Is there a way to get the location of a TrayItem?


回答1:


There's no platform-agnostic way to do this AFAIK. Ig you really need it, you'll likely need to code to the underlying SWT platform API as per your GTK example. One way I've done this which builds/runs everywhere is to use reflection to call the methods based on what SWT.getPlatform () returns.

If the window is mouse-triggered (e.g. by hover) you could consider using the mouse location as the base location for the hover.




回答2:


I haven't tried this, but since TrayItem extends Item, which is an instance of Widget, why not try this:

Tray tray = display.getSystemTray();
TrayItem trayItem = new TrayItem(tray, SWT.NONE);
Rectangle bounds = trayItem.getDisplay().getBounds();


来源:https://stackoverflow.com/questions/1960930/swt-trayitem-location

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