java.awt

Class TrayIcon

  • java.lang.Object
    • java.awt.TrayIcon
  • public class TrayIcon extends java.lang.Object
    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.

    Since:
    1.6
    See Also:
    SystemTray.add(java.awt.TrayIcon), ComponentEvent.getComponent(), EventObject.getSource()
    • Nested Classes 
      Modifier and Type Class and Description
      Ordinary member indicator MessageType Reveal DetailHide Detail
      The message type determines which icon will be displayed in the caption of the message, and a possible system sound a message may generate upon showing.
    • Constructors 
      Constructor and Description
      Ordinary member indicator TrayIcon Reveal DetailHide Detail
      Creates a TrayIcon with the specified image.
      Ordinary member indicator TrayIcon Reveal DetailHide Detail
      Creates a TrayIcon with the specified image and tooltip text.
      Ordinary member indicator TrayIcon Reveal DetailHide Detail
      Creates a TrayIcon with the specified image, tooltip and popup menu.
    • Methods 
      Modifier and Type Method and Description
      Ordinary member indicator addActionListener Reveal DetailHide Detail
      Adds the specified action listener to receive ActionEvents from this TrayIcon.
      Ordinary member indicator addMouseListener Reveal DetailHide Detail
      Adds the specified mouse listener to receive mouse events from this TrayIcon.
      Ordinary member indicator addMouseMotionListener Reveal DetailHide Detail
      Adds the specified mouse listener to receive mouse-motion events from this TrayIcon.
      Ordinary member indicator displayMessage Reveal DetailHide Detail
      Displays a popup message near the tray icon.
      Ordinary member indicator getActionCommand Reveal DetailHide Detail
      Returns the command name of the action event fired by this tray icon.
      Ordinary member indicator getActionListeners Reveal DetailHide Detail
      Returns an array of all the action listeners registered on this TrayIcon.
      Ordinary member indicator getImage Reveal DetailHide Detail
      Returns the current image used for this TrayIcon.
      Ordinary member indicator getMouseListeners Reveal DetailHide Detail
      Returns an array of all the mouse listeners registered on this TrayIcon.
      Ordinary member indicator getMouseMotionListeners Reveal DetailHide Detail
      Returns an array of all the mouse-motion listeners registered on this TrayIcon.
      Ordinary member indicator getPopupMenu Reveal DetailHide Detail
      Returns the popup menu associated with this TrayIcon.
      Ordinary member indicator getSize Reveal DetailHide Detail
      Returns the size, in pixels, of the space that the tray icon occupies in the system tray.
      Ordinary member indicator getToolTip Reveal DetailHide Detail
      Returns the tooltip string associated with this TrayIcon.
      Ordinary member indicator isImageAutoSize Reveal DetailHide Detail
      Returns the value of the auto-size property.
      Ordinary member indicator removeActionListener Reveal DetailHide Detail
      Removes the specified action listener.
      Ordinary member indicator removeMouseListener Reveal DetailHide Detail
      Removes the specified mouse listener.
      Ordinary member indicator removeMouseMotionListener Reveal DetailHide Detail
      Removes the specified mouse-motion listener.
      Ordinary member indicator setActionCommand Reveal DetailHide Detail
      Sets the command name for the action event fired by this tray icon.
      Ordinary member indicator setImage Reveal DetailHide Detail
      Sets the image for this TrayIcon.
      Ordinary member indicator setImageAutoSize Reveal DetailHide Detail
      Sets the auto-size property.
      Ordinary member indicator setPopupMenu Reveal DetailHide Detail
      Sets the popup menu for this TrayIcon.
      Ordinary member indicator setToolTip Reveal DetailHide Detail
      Sets the tooltip string for this TrayIcon.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
This document was created by Dulcet from the OpenJDK sources. Copyright © 1993, 2012 Oracle and/or its affiliates. All rights reserved.

SourceForge