Class SysTray

  • Direct Known Subclasses:
    SysTray.Java6SysTray, SysTray.NoSysTray

    public abstract class SysTray
    extends java.lang.Object
    Provides basic access to the windowing system's System Tray. This is a facade for a subset of the Java 1.6 java.awt.SystemTray functionality. When running in a J2SE1.6 JRE it will use reflection to access the underlying classes. In an earlier JRE, it will report lack of support.
    Since:
    20 Jul 2010
    Author:
    Mark Taylor
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  SysTray.Java6SysTray
      Implementation which provides system tray access using J2SE 1.6 classes by reflection.
      private static class  SysTray.NoSysTray
      Implementation which provides no system tray access.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static SysTray instance_  
      private static java.util.logging.Logger logger_  
    • Constructor Summary

      Constructors 
      Constructor Description
      SysTray()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract java.lang.Object addIcon​(java.awt.Image im, java.lang.String tooltip, java.awt.PopupMenu popup, java.awt.event.ActionListener iconListener)
      Adds an icon to the system tray.
      static SysTray getInstance()
      Returns an instance of this class.
      abstract boolean isSupported()
      Indicates whether system tray functionality is available.
      abstract void removeIcon​(java.lang.Object trayIcon)
      Removes a previously-added icon from the tray.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • instance_

        private static SysTray instance_
      • logger_

        private static final java.util.logging.Logger logger_
    • Constructor Detail

      • SysTray

        public SysTray()
    • Method Detail

      • isSupported

        public abstract boolean isSupported()
        Indicates whether system tray functionality is available.
        Returns:
        true iff the addIcon/removeIcon methods are expected to work
      • addIcon

        public abstract java.lang.Object addIcon​(java.awt.Image im,
                                                 java.lang.String tooltip,
                                                 java.awt.PopupMenu popup,
                                                 java.awt.event.ActionListener iconListener)
                                          throws java.awt.AWTException
        Adds an icon to the system tray.
        Parameters:
        im - image for display
        tooltip - tooltip text, or null
        popup - popup menu, or null
        iconListener - listener triggered when icon is activated, or null
        Returns:
        tray icon object, may be used for later removal
        Throws:
        java.awt.AWTException
      • removeIcon

        public abstract void removeIcon​(java.lang.Object trayIcon)
                                 throws java.awt.AWTException
        Removes a previously-added icon from the tray.
        Parameters:
        trayIcon - object obtained from a previous invocation of addIcon
        Throws:
        java.awt.AWTException
      • getInstance

        public static SysTray getInstance()
        Returns an instance of this class.
        Returns:
        instance