问题
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