| |
|
| java.lang.Object java.awt.TrayIcon
TrayIcon | public class TrayIcon (Code) | | A TrayIcon object represents a tray icon that can be
added to the
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
MouseEventMouseEvents and supports adding corresponding listeners to receive
notification 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
java.awt.event.ComponentEvent.getComponent ) The
source property will be set to this
TrayIcon . (See
java.util.EventObject.getSource )
Note: A well-behaved
TrayIcon implementation
will assign different gestures to showing a popup menu and
selecting a tray icon.
A TrayIcon can generate an
ActionEventActionEvent . 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
accessSystemTray must be granted in order to create
a
TrayIcon . Otherwise the constructor will throw a
SecurityException.
See the
SystemTray class overview for an example on how
to use the TrayIcon API.
since: 1.6 See Also: SystemTray.add See Also: java.awt.event.ComponentEvent.getComponent See Also: java.util.EventObject.getSource author: Bino George author: Denis Mikhalkin author: Sharon Zakhour author: Anton Tarasov |
Inner Class :public enum MessageType | |
Constructor Summary | |
public | TrayIcon(Image image) Creates a TrayIcon with the specified image. | public | TrayIcon(Image image, String tooltip) Creates a TrayIcon with the specified image and
tooltip text. | public | TrayIcon(Image image, String tooltip, PopupMenu popup) Creates a TrayIcon with the specified image,
tooltip and popup menu. |
displayMessage | public void displayMessage(String caption, String text, MessageType messageType)(Code) | | Displays a popup message near the tray icon. The message will
disappear after a time or if the user clicks on it. Clicking
on the message may trigger an
ActionEvent .
Either the caption or the text may be null , but an
NullPointerException is thrown if both are
null .
When displayed, the caption or text strings may be truncated on
some platforms; the number of characters that may be displayed is
platform-dependent.
Note: Some platforms may not support
showing a message.
Parameters: caption - the caption displayed above the text, usually inbold; may be null Parameters: text - the text displayed for the particular message; may benull Parameters: messageType - an enum indicating the message type throws: NullPointerException - if both caption and text are null |
getListeners | T[] getListeners(Class<T> listenerType)(Code) | | |
removeNotify | void removeNotify()(Code) | | |
setID | void setID(int id)(Code) | | |
setImageAutoSize | public void setImageAutoSize(boolean autosize)(Code) | | Sets the auto-size property. Auto-size determines whether the
tray image is automatically sized to fit the space allocated
for the image on the tray. By default, the auto-size property
is set to false .
If auto-size is false , and the image size
doesn't match the tray icon space, the image is painted as-is
inside that space if larger than the allocated space, it will
be cropped.
If auto-size is true , the image is stretched or shrunk to
fit the tray icon space.
Parameters: autosize - true to auto-size the image,false otherwise See Also: TrayIcon.isImageAutoSize |
setPopupMenu | public void setPopupMenu(PopupMenu popup)(Code) | | Sets the popup menu for this TrayIcon . If
popup is null , no popup menu will be
associated with this TrayIcon .
Note that this popup must not be added to any
parent before or after it is set on the tray icon. If you add
it to some parent, the popup may be removed from
that parent.
The
popup can be set on one
TrayIcon only.
Setting the same popup on multiple
TrayIcon s will cause
an
IllegalArgumentException .
Note: Some platforms may not support
showing the user-specified popup menu component when the user
right-clicks the tray icon. In this situation, either no menu
will be displayed or, on some systems, a native version of the
menu may be displayed.
throws: IllegalArgumentException - if the popup is alreadyset for another TrayIcon Parameters: popup - a PopupMenu or null toremove any popup menu See Also: TrayIcon.getPopupMenu |
setToolTip | public void setToolTip(String tooltip)(Code) | | Sets the tooltip string for this TrayIcon . The
tooltip is displayed automatically when the mouse hovers over
the icon. Setting the tooltip to null removes any
tooltip text.
When displayed, the tooltip string may be truncated on some platforms;
the number of characters that may be displayed is platform-dependent.
Parameters: tooltip - the string for the tooltip; if the value isnull no tooltip is shown See Also: TrayIcon.getToolTip |
|
|
|