src/share/classes/java/awt/SystemTray.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 320      * application.  You can't access the icons added by another
 321      * application.  Some browsers partition applets in different
 322      * code bases into separate contexts, and establish walls between
 323      * these contexts.  In such a scenario, only the tray icons added
 324      * from this context will be returned.
 325      *
 326      * <p> The returned array is a copy of the actual array and may be
 327      * modified in any way without affecting the system tray.  To
 328      * remove a <code>TrayIcon</code> from the
 329      * <code>SystemTray</code>, use the {@link
 330      * #remove(TrayIcon)} method.
 331      *
 332      * @return an array of all tray icons added to this tray, or an
 333      * empty array if none has been added
 334      * @see #add(TrayIcon)
 335      * @see TrayIcon
 336      */
 337     public TrayIcon[] getTrayIcons() {
 338         Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
 339         if (icons != null) {
 340             return (TrayIcon[])icons.toArray(new TrayIcon[icons.size()]);
 341         }
 342         return EMPTY_TRAY_ARRAY;
 343     }
 344 
 345     /**
 346      * Returns the size, in pixels, of the space that a tray icon will
 347      * occupy in the system tray.  Developers may use this methods to
 348      * acquire the preferred size for the image property of a tray icon
 349      * before it is created.  For convenience, there is a similar
 350      * method {@link TrayIcon#getSize} in the <code>TrayIcon</code> class.
 351      *
 352      * @return the default size of a tray icon, in pixels
 353      * @see TrayIcon#setImageAutoSize(boolean)
 354      * @see java.awt.Image
 355      * @see TrayIcon#getSize()
 356      */
 357     public Dimension getTrayIconSize() {
 358         return peer.getTrayIconSize();
 359     }
 360 


   1 /*
   2  * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 320      * application.  You can't access the icons added by another
 321      * application.  Some browsers partition applets in different
 322      * code bases into separate contexts, and establish walls between
 323      * these contexts.  In such a scenario, only the tray icons added
 324      * from this context will be returned.
 325      *
 326      * <p> The returned array is a copy of the actual array and may be
 327      * modified in any way without affecting the system tray.  To
 328      * remove a <code>TrayIcon</code> from the
 329      * <code>SystemTray</code>, use the {@link
 330      * #remove(TrayIcon)} method.
 331      *
 332      * @return an array of all tray icons added to this tray, or an
 333      * empty array if none has been added
 334      * @see #add(TrayIcon)
 335      * @see TrayIcon
 336      */
 337     public TrayIcon[] getTrayIcons() {
 338         Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
 339         if (icons != null) {
 340             return icons.toArray(new TrayIcon[icons.size()]);
 341         }
 342         return EMPTY_TRAY_ARRAY;
 343     }
 344 
 345     /**
 346      * Returns the size, in pixels, of the space that a tray icon will
 347      * occupy in the system tray.  Developers may use this methods to
 348      * acquire the preferred size for the image property of a tray icon
 349      * before it is created.  For convenience, there is a similar
 350      * method {@link TrayIcon#getSize} in the <code>TrayIcon</code> class.
 351      *
 352      * @return the default size of a tray icon, in pixels
 353      * @see TrayIcon#setImageAutoSize(boolean)
 354      * @see java.awt.Image
 355      * @see TrayIcon#getSize()
 356      */
 357     public Dimension getTrayIconSize() {
 358         return peer.getTrayIconSize();
 359     }
 360