A TrayIcon object represents a tray icon that can be added to the 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 MouseEvents 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 ComponentEvent.getComponent()) The source property will be set to this TrayIcon. (See 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 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 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.
A TrayIcon object represents a tray icon that can be added to the 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 MouseEvents 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 ComponentEvent.getComponent()) The source property will be set to this TrayIcon. (See 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 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 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.
(->tray-icon image)
(->tray-icon image tooltip)
(->tray-icon image tooltip popup)
Constructor.
Creates a TrayIcon with the specified image, tooltip and popup menu.
image - the Image to be used - java.awt.Image
tooltip - the string to be used as tooltip text; if the value is null no tooltip is shown - java.lang.String
popup - the menu to be used for the tray icon's popup menu; if the value is null no popup menu is shown - java.awt.PopupMenu
throws: java.lang.IllegalArgumentException - if image is null
Constructor. Creates a TrayIcon with the specified image, tooltip and popup menu. image - the Image to be used - `java.awt.Image` tooltip - the string to be used as tooltip text; if the value is null no tooltip is shown - `java.lang.String` popup - the menu to be used for the tray icon's popup menu; if the value is null no popup menu is shown - `java.awt.PopupMenu` throws: java.lang.IllegalArgumentException - if image is null
(add-action-listener this listener)
Adds the specified action listener to receive ActionEvents from this TrayIcon. Action events usually occur when a user selects the tray icon, using either the mouse or keyboard. The conditions in which action events are generated are platform-dependent.
Calling this method with a null value has no effect. Refer to AWT Threading Issues for details on AWT's threading model.
listener - the action listener - java.awt.event.ActionListener
Adds the specified action listener to receive ActionEvents from this TrayIcon. Action events usually occur when a user selects the tray icon, using either the mouse or keyboard. The conditions in which action events are generated are platform-dependent. Calling this method with a null value has no effect. Refer to AWT Threading Issues for details on AWT's threading model. listener - the action listener - `java.awt.event.ActionListener`
(add-mouse-listener this listener)
Adds the specified mouse listener to receive mouse events from this TrayIcon. Calling this method with a null value has no effect.
Note: The MouseEvent's coordinates (received from the TrayIcon) are relative to the screen, not the TrayIcon.
Note: The MOUSE_ENTERED and MOUSE_EXITED mouse events are not supported. Refer to AWT Threading Issues for details on AWT's threading model.
listener - the mouse listener - java.awt.event.MouseListener
Adds the specified mouse listener to receive mouse events from this TrayIcon. Calling this method with a null value has no effect. Note: The MouseEvent's coordinates (received from the TrayIcon) are relative to the screen, not the TrayIcon. Note: The MOUSE_ENTERED and MOUSE_EXITED mouse events are not supported. Refer to AWT Threading Issues for details on AWT's threading model. listener - the mouse listener - `java.awt.event.MouseListener`
(add-mouse-motion-listener this listener)
Adds the specified mouse listener to receive mouse-motion events from this TrayIcon. Calling this method with a null value has no effect.
Note: The MouseEvent's coordinates (received from the TrayIcon) are relative to the screen, not the TrayIcon.
Note: The MOUSE_DRAGGED mouse event is not supported. Refer to AWT Threading Issues for details on AWT's threading model.
listener - the mouse listener - java.awt.event.MouseMotionListener
Adds the specified mouse listener to receive mouse-motion events from this TrayIcon. Calling this method with a null value has no effect. Note: The MouseEvent's coordinates (received from the TrayIcon) are relative to the screen, not the TrayIcon. Note: The MOUSE_DRAGGED mouse event is not supported. Refer to AWT Threading Issues for details on AWT's threading model. listener - the mouse listener - `java.awt.event.MouseMotionListener`
(display-message this caption text message-type)
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.
caption - the caption displayed above the text, usually in bold; may be null - java.lang.String
text - the text displayed for the particular message; may be null - java.lang.String
message-type - an enum indicating the message type - java.awt.TrayIcon$MessageType
throws: java.lang.NullPointerException - if both caption and text are null
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. caption - the caption displayed above the text, usually in bold; may be null - `java.lang.String` text - the text displayed for the particular message; may be null - `java.lang.String` message-type - an enum indicating the message type - `java.awt.TrayIcon$MessageType` throws: java.lang.NullPointerException - if both caption and text are null
(get-action-command this)
Returns the command name of the action event fired by this tray icon.
returns: the action command name, or null if none exists - java.lang.String
Returns the command name of the action event fired by this tray icon. returns: the action command name, or null if none exists - `java.lang.String`
(get-action-listeners this)
Returns an array of all the action listeners registered on this TrayIcon.
returns: all of the ActionListeners registered on
this TrayIcon or an empty array if no action
listeners are currently registered - java.awt.event.ActionListener[]
Returns an array of all the action listeners registered on this TrayIcon. returns: all of the ActionListeners registered on this TrayIcon or an empty array if no action listeners are currently registered - `java.awt.event.ActionListener[]`
(get-image this)
Returns the current image used for this TrayIcon.
returns: the image - java.awt.Image
Returns the current image used for this TrayIcon. returns: the image - `java.awt.Image`
(get-mouse-listeners this)
Returns an array of all the mouse listeners registered on this TrayIcon.
returns: all of the MouseListeners registered on
this TrayIcon or an empty array if no mouse
listeners are currently registered - java.awt.event.MouseListener[]
Returns an array of all the mouse listeners registered on this TrayIcon. returns: all of the MouseListeners registered on this TrayIcon or an empty array if no mouse listeners are currently registered - `java.awt.event.MouseListener[]`
(get-mouse-motion-listeners this)
Returns an array of all the mouse-motion listeners registered on this TrayIcon.
returns: all of the MouseInputListeners registered on
this TrayIcon or an empty array if no mouse
listeners are currently registered - java.awt.event.MouseMotionListener[]
Returns an array of all the mouse-motion listeners registered on this TrayIcon. returns: all of the MouseInputListeners registered on this TrayIcon or an empty array if no mouse listeners are currently registered - `java.awt.event.MouseMotionListener[]`
(get-popup-menu this)
Returns the popup menu associated with this TrayIcon.
returns: the popup menu or null if none exists - java.awt.PopupMenu
Returns the popup menu associated with this TrayIcon. returns: the popup menu or null if none exists - `java.awt.PopupMenu`
(get-size this)
Returns the size, in pixels, of the space that the tray icon occupies in the system tray. For the tray icon that is not yet added to the system tray, the returned size is equal to the result of the SystemTray.getTrayIconSize().
returns: the size of the tray icon, in pixels - java.awt.Dimension
Returns the size, in pixels, of the space that the tray icon occupies in the system tray. For the tray icon that is not yet added to the system tray, the returned size is equal to the result of the SystemTray.getTrayIconSize(). returns: the size of the tray icon, in pixels - `java.awt.Dimension`
(get-tool-tip this)
Returns the tooltip string associated with this TrayIcon.
returns: the tooltip string or null if none exists - java.lang.String
Returns the tooltip string associated with this TrayIcon. returns: the tooltip string or null if none exists - `java.lang.String`
(image-auto-size? this)
Returns the value of the auto-size property.
returns: true if the image will be auto-sized,
false otherwise - boolean
Returns the value of the auto-size property. returns: true if the image will be auto-sized, false otherwise - `boolean`
(remove-action-listener this listener)
Removes the specified action listener. Calling this method with null or an invalid value has no effect. Refer to AWT Threading Issues for details on AWT's threading model.
listener - the action listener - java.awt.event.ActionListener
Removes the specified action listener. Calling this method with null or an invalid value has no effect. Refer to AWT Threading Issues for details on AWT's threading model. listener - the action listener - `java.awt.event.ActionListener`
(remove-mouse-listener this listener)
Removes the specified mouse listener. Calling this method with null or an invalid value has no effect. Refer to AWT Threading Issues for details on AWT's threading model.
listener - the mouse listener - java.awt.event.MouseListener
Removes the specified mouse listener. Calling this method with null or an invalid value has no effect. Refer to AWT Threading Issues for details on AWT's threading model. listener - the mouse listener - `java.awt.event.MouseListener`
(remove-mouse-motion-listener this listener)
Removes the specified mouse-motion listener. Calling this method with null or an invalid value has no effect. Refer to AWT Threading Issues for details on AWT's threading model.
listener - the mouse listener - java.awt.event.MouseMotionListener
Removes the specified mouse-motion listener. Calling this method with null or an invalid value has no effect. Refer to AWT Threading Issues for details on AWT's threading model. listener - the mouse listener - `java.awt.event.MouseMotionListener`
(set-action-command this command)
Sets the command name for the action event fired by this tray icon. By default, this action command is set to null.
command - a string used to set the tray icon's action command. - java.lang.String
Sets the command name for the action event fired by this tray icon. By default, this action command is set to null. command - a string used to set the tray icon's action command. - `java.lang.String`
(set-image this image)
Sets the image for this TrayIcon. The previous tray icon image is discarded without calling the Image.flush() method you will need to call it manually.
If the image represents an animated image, it will be animated automatically.
See the setImageAutoSize(boolean) property for details on the size of the displayed image.
Calling this method with the same image that is currently being used has no effect.
image - the non-null Image to be used - java.awt.Image
throws: java.lang.NullPointerException - if image is null
Sets the image for this TrayIcon. The previous tray icon image is discarded without calling the Image.flush() method you will need to call it manually. If the image represents an animated image, it will be animated automatically. See the setImageAutoSize(boolean) property for details on the size of the displayed image. Calling this method with the same image that is currently being used has no effect. image - the non-null Image to be used - `java.awt.Image` throws: java.lang.NullPointerException - if image is null
(set-image-auto-size this autosize)
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.
autosize - true to auto-size the image, false otherwise - boolean
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. autosize - true to auto-size the image, false otherwise - `boolean`
(set-popup-menu this popup)
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 TrayIcons 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.
popup - a PopupMenu or null to remove any popup menu - java.awt.PopupMenu
throws: java.lang.IllegalArgumentException - if the popup is already set for another TrayIcon
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 TrayIcons 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. popup - a PopupMenu or null to remove any popup menu - `java.awt.PopupMenu` throws: java.lang.IllegalArgumentException - if the popup is already set for another TrayIcon
(set-tool-tip this tooltip)
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.
tooltip - the string for the tooltip; if the value is null no tooltip is shown - java.lang.String
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. tooltip - the string for the tooltip; if the value is null no tooltip is shown - `java.lang.String`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close