-
Enhancement
-
Resolution: Unresolved
-
P5
-
None
-
6
-
Cause Known
-
x86
-
linux
A DESCRIPTION OF THE REQUEST :
java.awt.TrayIcon should have a public Point getLocationOnScreen() method.
JUSTIFICATION :
The TrayIcon API is very limited; at the moment you can only get it to show a text message, display a tooltip, and show a java.awt.PopupMenu. You can also have it respond to MouseEvents, for which, since you have the coordinates on the screen, you can have just about any sort of Java component show up. But this workaround isn't available for application-generated events; you can pop up a custom JDialog in the correct location for a mouse click, but not to indicate that the application state changed. Thus, the need for a getLocationOnScreen() method.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
java.awt.TrayIcon.getLocationOnScreen() should return an instance of Point representing the top-left corner of the component's bounds in the coordinate space of the screen, just as java.awt.Component.getLocationOnScreen() does.
ACTUAL -
This method does not currently exist.
CUSTOMER SUBMITTED WORKAROUND :
You could grab the location of the first MouseEvent and store it (and hope that the TrayIcon doesn't move), but that requires that the mouse would have interacted with the TrayIcon before you want to show any custom dialogs.
java.awt.TrayIcon should have a public Point getLocationOnScreen() method.
JUSTIFICATION :
The TrayIcon API is very limited; at the moment you can only get it to show a text message, display a tooltip, and show a java.awt.PopupMenu. You can also have it respond to MouseEvents, for which, since you have the coordinates on the screen, you can have just about any sort of Java component show up. But this workaround isn't available for application-generated events; you can pop up a custom JDialog in the correct location for a mouse click, but not to indicate that the application state changed. Thus, the need for a getLocationOnScreen() method.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
java.awt.TrayIcon.getLocationOnScreen() should return an instance of Point representing the top-left corner of the component's bounds in the coordinate space of the screen, just as java.awt.Component.getLocationOnScreen() does.
ACTUAL -
This method does not currently exist.
CUSTOMER SUBMITTED WORKAROUND :
You could grab the location of the first MouseEvent and store it (and hope that the TrayIcon doesn't move), but that requires that the mouse would have interacted with the TrayIcon before you want to show any custom dialogs.
- duplicates
-
JDK-6713280 consider implementing TrayIcon.getLocationOnScreen()
- Closed
- relates to
-
JDK-8150540 [TEST_BUG] TrayIcon tests: could SystemTrayIconHelper's getTrayIconLocation() be reworked in more reliable way for Windows?
- Open