TrayIcon
object represents a tray icon that can be added to the {@link SystemTray system tray}. A TrayIcon
can have a tooltip (text), an image, a popup menu, and a set of listeners associated with it. A TrayIcon
can generate various {@link MouseEvent MouseEvents} and supports adding corresponding listeners to receivenotification of these events. TrayIcon
processes some of the events by itself. For example, by default, when the right-mouse click is performed on the TrayIcon
it displays the specified popup menu. When the mouse hovers over the TrayIcon
the tooltip is displayed.
Note: When the MouseEvent
is dispatched to its registered listeners its component
property will be set to null
. (See {@link java.awt.event.ComponentEvent#getComponent}) The source
property will be set to this TrayIcon
. (See {@link java.util.EventObject#getSource})
Note: A well-behaved {@link TrayIcon} implementationwill assign different gestures to showing a popup menu and selecting a tray icon.
A TrayIcon
can generate an {@link ActionEvent ActionEvent}. On some platforms, this occurs when the user selects the tray icon using either the mouse or keyboard.
If a SecurityManager is installed, the AWTPermission {@code accessSystemTray} must be granted in order to createa {@code TrayIcon}. Otherwise the constructor will throw a SecurityException.
See the {@link SystemTray} class overview for an example on howto use the TrayIcon
API.
@since 1.6
@see SystemTray#add
@see java.awt.event.ComponentEvent#getComponent
@see java.util.EventObject#getSource
@author Bino George
@author Denis Mikhalkin
@author Sharon Zakhour
@author Anton Tarasov
|
|
|
|