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

Print this page

        

@@ -257,11 +257,13 @@
         }
         TrayIcon[] oldArray = null, newArray = null;
         Vector<TrayIcon> icons = null;
         synchronized (this) {
             oldArray = systemTray.getTrayIcons();
-            icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
+            @SuppressWarnings("unchecked")
+            Vector<TrayIcon> tmp = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
+            icons = tmp;
             if (icons == null) {
                 icons = new Vector<TrayIcon>(3);
                 AppContext.getAppContext().put(TrayIcon.class, icons);
 
             } else if (icons.contains(trayIcon)) {

@@ -302,10 +304,11 @@
             return;
         }
         TrayIcon[] oldArray = null, newArray = null;
         synchronized (this) {
             oldArray = systemTray.getTrayIcons();
+            @SuppressWarnings("unchecked")
             Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
             // TrayIcon with no peer is not contained in the array.
             if (icons == null || !icons.remove(trayIcon)) {
                 return;
             }

@@ -333,10 +336,11 @@
      * empty array if none has been added
      * @see #add(TrayIcon)
      * @see TrayIcon
      */
     public TrayIcon[] getTrayIcons() {
+        @SuppressWarnings("unchecked")
         Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
         if (icons != null) {
             return icons.toArray(new TrayIcon[icons.size()]);
         }
         return EMPTY_TRAY_ARRAY;