3909N/A * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A <code>TrayIcon</code> object represents a tray icon that can be 0N/A * added to the {@link SystemTray system tray}. A 0N/A * <code>TrayIcon</code> can have a tooltip (text), an image, a popup 0N/A * menu, and a set of listeners associated with it. 0N/A * <p>A <code>TrayIcon</code> can generate various {@link MouseEvent 0N/A * MouseEvents} and supports adding corresponding listeners to receive 0N/A * notification of these events. <code>TrayIcon</code> processes some 0N/A * of the events by itself. For example, by default, when the 0N/A * right-mouse click is performed on the <code>TrayIcon</code> it 0N/A * displays the specified popup menu. When the mouse hovers 0N/A * over the <code>TrayIcon</code> the tooltip is displayed. 0N/A * <p><strong>Note:</strong> When the <code>MouseEvent</code> is 0N/A * dispatched to its registered listeners its <code>component</code> 0N/A * property will be set to <code>null</code>. (See {@link 0N/A * java.awt.event.ComponentEvent#getComponent}) The 0N/A * <code>source</code> property will be set to this 0N/A * <code>TrayIcon</code>. (See {@link 0N/A * java.util.EventObject#getSource}) 0N/A * <p><b>Note:</b> A well-behaved {@link TrayIcon} implementation 0N/A * will assign different gestures to showing a popup menu and 0N/A * selecting a tray icon. 0N/A * <p>A <code>TrayIcon</code> can generate an {@link ActionEvent 0N/A * ActionEvent}. On some platforms, this occurs when the user selects 0N/A * the tray icon using either the mouse or keyboard. 0N/A * <p>If a SecurityManager is installed, the AWTPermission 0N/A * {@code accessSystemTray} must be granted in order to create 0N/A * a {@code TrayIcon}. Otherwise the constructor will throw a 0N/A * SecurityException. 0N/A * <p> See the {@link SystemTray} class overview for an example on how 0N/A * to use the <code>TrayIcon</code> API. 0N/A * @see SystemTray#add 0N/A * @see java.awt.event.ComponentEvent#getComponent 0N/A * @see java.util.EventObject#getSource 0N/A * @author Bino George 0N/A * @author Denis Mikhalkin 0N/A * @author Sharon Zakhour 0N/A * @author Anton Tarasov 3787N/A * The tray icon's AccessControlContext. 3787N/A * Unlike the acc in Component, this field is made final 3787N/A * because TrayIcon is not serializable. 3787N/A * Returns the acc this tray icon was constructed with. 0N/A * Creates a <code>TrayIcon</code> with the specified image. 0N/A * @param image the <code>Image</code> to be used 0N/A * @throws IllegalArgumentException if <code>image</code> is 0N/A * @throws UnsupportedOperationException if the system tray isn't 0N/A * supported by the current platform 0N/A * @throws HeadlessException if 0N/A * {@code GraphicsEnvironment.isHeadless()} returns {@code true} 0N/A * @throws SecurityException if {@code accessSystemTray} permission 0N/A * @see SystemTray#add(TrayIcon) 0N/A * @see TrayIcon#TrayIcon(Image, String, PopupMenu) 0N/A * @see TrayIcon#TrayIcon(Image, String) 0N/A * @see SecurityManager#checkPermission 0N/A * @see AWTPermission 0N/A * Creates a <code>TrayIcon</code> with the specified image and 0N/A * @param image the <code>Image</code> to be used 0N/A * @param tooltip the string to be used as tooltip text; if the 0N/A * value is <code>null</code> no tooltip is shown 0N/A * @throws IllegalArgumentException if <code>image</code> is 0N/A * @throws UnsupportedOperationException if the system tray isn't 0N/A * supported by the current platform 0N/A * @throws HeadlessException if 0N/A * {@code GraphicsEnvironment.isHeadless()} returns {@code true} 0N/A * @throws SecurityException if {@code accessSystemTray} permission 0N/A * @see SystemTray#add(TrayIcon) 0N/A * @see TrayIcon#TrayIcon(Image) 0N/A * @see TrayIcon#TrayIcon(Image, String, PopupMenu) 0N/A * @see SecurityManager#checkPermission 0N/A * @see AWTPermission 0N/A * Creates a <code>TrayIcon</code> with the specified image, 0N/A * tooltip and popup menu. 0N/A * @param image the <code>Image</code> to be used 0N/A * @param tooltip the string to be used as tooltip text; if the 0N/A * value is <code>null</code> no tooltip is shown 0N/A * @param popup the menu to be used for the tray icon's popup 0N/A * menu; if the value is <code>null</code> no popup menu is shown 0N/A * @throws IllegalArgumentException if <code>image</code> is <code>null</code> 0N/A * @throws UnsupportedOperationException if the system tray isn't 0N/A * supported by the current platform 0N/A * @throws HeadlessException if 0N/A * {@code GraphicsEnvironment.isHeadless()} returns {@code true} 0N/A * @throws SecurityException if {@code accessSystemTray} permission 0N/A * @see SystemTray#add(TrayIcon) 0N/A * @see TrayIcon#TrayIcon(Image, String) 0N/A * @see TrayIcon#TrayIcon(Image) 0N/A * @see MouseListener 0N/A * @see #addMouseListener(MouseListener) 0N/A * @see SecurityManager#checkPermission 0N/A * @see AWTPermission 0N/A * Sets the image for this <code>TrayIcon</code>. The previous 0N/A * tray icon image is discarded without calling the {@link 0N/A * java.awt.Image#flush} method — you will need to call it 0N/A * <p> If the image represents an animated image, it will be 0N/A * animated automatically. 0N/A * <p> See the {@link #setImageAutoSize(boolean)} property for 0N/A * details on the size of the displayed image. 0N/A * <p> Calling this method with the same image that is currently 0N/A * being used has no effect. 0N/A * @throws NullPointerException if <code>image</code> is <code>null</code> 0N/A * @param image the non-null <code>Image</code> to be used 0N/A * @see SystemTray#add(TrayIcon) 0N/A * @see TrayIcon#TrayIcon(Image, String) 0N/A * Returns the current image used for this <code>TrayIcon</code>. 0N/A * @see #setImage(Image) 0N/A * Sets the popup menu for this <code>TrayIcon</code>. If 0N/A * <code>popup</code> is <code>null</code>, no popup menu will be 0N/A * associated with this <code>TrayIcon</code>. 0N/A * <p>Note that this <code>popup</code> must not be added to any 0N/A * parent before or after it is set on the tray icon. If you add 0N/A * it to some parent, the <code>popup</code> may be removed from 0N/A * <p>The {@code popup} can be set on one {@code TrayIcon} only. 0N/A * Setting the same popup on multiple {@code TrayIcon}s will cause 0N/A * an {@code IllegalArgumentException}. 0N/A * <p><strong>Note:</strong> Some platforms may not support 0N/A * showing the user-specified popup menu component when the user 0N/A * right-clicks the tray icon. In this situation, either no menu 0N/A * will be displayed or, on some systems, a native version of the 0N/A * menu may be displayed. 0N/A * @throws IllegalArgumentException if the {@code popup} is already 0N/A * set for another {@code TrayIcon} 0N/A * @param popup a <code>PopupMenu</code> or <code>null</code> to 0N/A * remove any popup menu 0N/A * @see #getPopupMenu 0N/A * Returns the popup menu associated with this <code>TrayIcon</code>. 0N/A * @return the popup menu or <code>null</code> if none exists 0N/A * @see #setPopupMenu(PopupMenu) 0N/A * Sets the tooltip string for this <code>TrayIcon</code>. The 0N/A * tooltip is displayed automatically when the mouse hovers over 0N/A * the icon. Setting the tooltip to <code>null</code> removes any 0N/A * When displayed, the tooltip string may be truncated on some platforms; 0N/A * the number of characters that may be displayed is platform-dependent. 0N/A * @param tooltip the string for the tooltip; if the value is 0N/A * <code>null</code> no tooltip is shown 0N/A * Returns the tooltip string associated with this 0N/A * <code>TrayIcon</code>. 0N/A * @return the tooltip string or <code>null</code> if none exists 0N/A * @see #setToolTip(String) 0N/A * Sets the auto-size property. Auto-size determines whether the 0N/A * tray image is automatically sized to fit the space allocated 0N/A * for the image on the tray. By default, the auto-size property 0N/A * is set to <code>false</code>. 0N/A * <p> If auto-size is <code>false</code>, and the image size 0N/A * doesn't match the tray icon space, the image is painted as-is 0N/A * inside that space — if larger than the allocated space, it will 0N/A * <p> If auto-size is <code>true</code>, the image is stretched or shrunk to 0N/A * fit the tray icon space. 0N/A * @param autosize <code>true</code> to auto-size the image, 0N/A * <code>false</code> otherwise 0N/A * @see #isImageAutoSize 0N/A * Returns the value of the auto-size property. 0N/A * @return <code>true</code> if the image will be auto-sized, 0N/A * <code>false</code> otherwise 0N/A * @see #setImageAutoSize(boolean) 0N/A * Adds the specified mouse listener to receive mouse events from 0N/A * this <code>TrayIcon</code>. Calling this method with a 0N/A * <code>null</code> value has no effect. 0N/A * <p><b>Note</b>: The {@code MouseEvent}'s coordinates (received 0N/A * from the {@code TrayIcon}) are relative to the screen, not the 0N/A * <p> <b>Note: </b>The <code>MOUSE_ENTERED</code> and 0N/A * <code>MOUSE_EXITED</code> mouse events are not supported. 0N/A * >AWT Threading Issues</a> for details on AWT's threading model. 0N/A * @param listener the mouse listener 0N/A * @see java.awt.event.MouseEvent 0N/A * @see java.awt.event.MouseListener 0N/A * @see #removeMouseListener(MouseListener) 0N/A * @see #getMouseListeners 0N/A * Removes the specified mouse listener. Calling this method with 0N/A * <code>null</code> or an invalid value has no effect. 0N/A * >AWT Threading Issues</a> for details on AWT's threading model. 0N/A * @param listener the mouse listener 0N/A * @see java.awt.event.MouseEvent 0N/A * @see java.awt.event.MouseListener 0N/A * @see #addMouseListener(MouseListener) 0N/A * @see #getMouseListeners 0N/A * Returns an array of all the mouse listeners 0N/A * registered on this <code>TrayIcon</code>. 0N/A * @return all of the <code>MouseListeners</code> registered on 0N/A * this <code>TrayIcon</code> or an empty array if no mouse 0N/A * listeners are currently registered 0N/A * @see #addMouseListener(MouseListener) 0N/A * @see #removeMouseListener(MouseListener) 0N/A * @see java.awt.event.MouseListener 0N/A * Adds the specified mouse listener to receive mouse-motion 0N/A * events from this <code>TrayIcon</code>. Calling this method 0N/A * with a <code>null</code> value has no effect. 0N/A * <p><b>Note</b>: The {@code MouseEvent}'s coordinates (received 0N/A * from the {@code TrayIcon}) are relative to the screen, not the 0N/A * <p> <b>Note: </b>The <code>MOUSE_DRAGGED</code> mouse event is not supported. 0N/A * >AWT Threading Issues</a> for details on AWT's threading model. 0N/A * @param listener the mouse listener 0N/A * @see java.awt.event.MouseEvent 0N/A * @see java.awt.event.MouseMotionListener 0N/A * @see #removeMouseMotionListener(MouseMotionListener) 0N/A * @see #getMouseMotionListeners 0N/A * Removes the specified mouse-motion listener. Calling this method with 0N/A * <code>null</code> or an invalid value has no effect. 0N/A * >AWT Threading Issues</a> for details on AWT's threading model. 0N/A * @param listener the mouse listener 0N/A * @see java.awt.event.MouseEvent 0N/A * @see java.awt.event.MouseMotionListener 0N/A * @see #addMouseMotionListener(MouseMotionListener) 0N/A * @see #getMouseMotionListeners 0N/A * Returns an array of all the mouse-motion listeners 0N/A * registered on this <code>TrayIcon</code>. 0N/A * @return all of the <code>MouseInputListeners</code> registered on 0N/A * this <code>TrayIcon</code> or an empty array if no mouse 0N/A * listeners are currently registered 0N/A * @see #addMouseMotionListener(MouseMotionListener) 0N/A * @see #removeMouseMotionListener(MouseMotionListener) 0N/A * @see java.awt.event.MouseMotionListener 0N/A * Returns the command name of the action event fired by this tray icon. 0N/A * @return the action command name, or <code>null</code> if none exists 0N/A * @see #addActionListener(ActionListener) 0N/A * @see #setActionCommand(String) 0N/A * Sets the command name for the action event fired by this tray 0N/A * icon. By default, this action command is set to 0N/A * <code>null</code>. 0N/A * @param command a string used to set the tray icon's 0N/A * @see java.awt.event.ActionEvent 0N/A * @see #addActionListener(ActionListener) 0N/A * @see #getActionCommand 0N/A * Adds the specified action listener to receive 0N/A * <code>ActionEvent</code>s from this <code>TrayIcon</code>. 0N/A * Action events usually occur when a user selects the tray icon, 0N/A * using either the mouse or keyboard. The conditions in which 0N/A * action events are generated are platform-dependent. 0N/A * <p>Calling this method with a <code>null</code> value has no 0N/A * >AWT Threading Issues</a> for details on AWT's threading model. 0N/A * @param listener the action listener 0N/A * @see #removeActionListener 0N/A * @see #getActionListeners 0N/A * @see java.awt.event.ActionListener 0N/A * @see #setActionCommand(String) 0N/A * Removes the specified action listener. Calling this method with 0N/A * <code>null</code> or an invalid value has no effect. 0N/A * >AWT Threading Issues</a> for details on AWT's threading model. 0N/A * @param listener the action listener 0N/A * @see java.awt.event.ActionEvent 0N/A * @see java.awt.event.ActionListener 0N/A * @see #addActionListener(ActionListener) 0N/A * @see #getActionListeners 0N/A * @see #setActionCommand(String) 0N/A * Returns an array of all the action listeners 0N/A * registered on this <code>TrayIcon</code>. 0N/A * @return all of the <code>ActionListeners</code> registered on 0N/A * this <code>TrayIcon</code> or an empty array if no action 0N/A * listeners are currently registered 0N/A * @see #addActionListener(ActionListener) 0N/A * @see #removeActionListener(ActionListener) 0N/A * @see java.awt.event.ActionListener 0N/A * The message type determines which icon will be displayed in the 0N/A * caption of the message, and a possible system sound a message 0N/A * may generate upon showing. 0N/A * @see TrayIcon#displayMessage(String, String, MessageType) 0N/A /** An error message */ 0N/A /** A warning message */ 0N/A /** An information message */ 0N/A /** Simple message */ 0N/A * Displays a popup message near the tray icon. The message will 0N/A * disappear after a time or if the user clicks on it. Clicking 0N/A * on the message may trigger an {@code ActionEvent}. 0N/A * <p>Either the caption or the text may be <code>null</code>, but an 0N/A * <code>NullPointerException</code> is thrown if both are 0N/A * <code>null</code>. 0N/A * When displayed, the caption or text strings may be truncated on 0N/A * some platforms; the number of characters that may be displayed is 0N/A * platform-dependent. 0N/A * <p><strong>Note:</strong> Some platforms may not support 0N/A * showing a message. 0N/A * @param caption the caption displayed above the text, usually in 0N/A * bold; may be <code>null</code> 0N/A * @param text the text displayed for the particular message; may be 0N/A * @param messageType an enum indicating the message type 0N/A * @throws NullPointerException if both <code>caption</code> 0N/A * and <code>text</code> are <code>null</code> 0N/A * Returns the size, in pixels, of the space that the tray icon 0N/A * occupies in the system tray. For the tray icon that is not yet 0N/A * added to the system tray, the returned size is equal to the 0N/A * result of the {@link SystemTray#getTrayIconSize}. 0N/A * @return the size of the tray icon, in pixels 0N/A * @see TrayIcon#setImageAutoSize(boolean) 0N/A * @see java.awt.Image 0N/A * @see TrayIcon#getSize() 0N/A // **************************************************************** 0N/A // **************************************************************** 0N/A synchronized (
this) {
0N/A synchronized (
this) {