jdk/src/share/classes/javax/swing/JPopupMenu.java
changeset 1301 15e81207e1f2
parent 715 f16baef3a20e
child 3956 2586d23078e4
--- a/jdk/src/share/classes/javax/swing/JPopupMenu.java	Tue Aug 26 12:16:23 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/JPopupMenu.java	Tue Aug 26 15:12:54 2008 +0400
@@ -584,7 +584,7 @@
 
         int nitems = getComponentCount();
         // PENDING(ges): Why not use an array?
-        Vector tempItems = new Vector();
+        Vector<Component> tempItems = new Vector<Component>();
 
         /* Remove the item at index, nitems-index times
            storing them in a temporary vector in the
@@ -600,8 +600,8 @@
         /* Add the removed items back to the menu, they are
            already in the correct order in the temp vector.
            */
-        for (int i = 0; i < tempItems.size()  ; i++) {
-            add((Component)tempItems.elementAt(i));
+        for (Component tempItem : tempItems) {
+            add(tempItem);
         }
     }
 
@@ -632,8 +632,7 @@
      * @since 1.4
      */
     public PopupMenuListener[] getPopupMenuListeners() {
-        return (PopupMenuListener[])listenerList.getListeners(
-                PopupMenuListener.class);
+        return listenerList.getListeners(PopupMenuListener.class);
     }
 
     /**
@@ -665,8 +664,7 @@
      * @since 1.5
      */
     public MenuKeyListener[] getMenuKeyListeners() {
-        return (MenuKeyListener[])listenerList.getListeners(
-                MenuKeyListener.class);
+        return listenerList.getListeners(MenuKeyListener.class);
     }
 
     /**
@@ -781,7 +779,7 @@
             // set selection path before popping up!
             if (isPopupMenu()) {
                 MenuElement me[] = new MenuElement[1];
-                me[0] = (MenuElement) this;
+                me[0] = this;
                 MenuSelectionManager.defaultManager().setSelectedPath(me);
             }
         }
@@ -848,10 +846,7 @@
      * being displayed).
      */
     public boolean isVisible() {
-        if(popup != null)
-            return true;
-        else
-            return false;
+        return popup != null;
     }
 
     /**
@@ -1311,7 +1306,7 @@
 // Serialization support.
 ////////////
     private void writeObject(ObjectOutputStream s) throws IOException {
-        Vector      values = new Vector();
+        Vector<Object> values = new Vector<Object>();
 
         s.defaultWriteObject();
         // Save the invoker, if its Serializable.
@@ -1494,7 +1489,7 @@
      */
     public MenuElement[] getSubElements() {
         MenuElement result[];
-        Vector tmp = new Vector();
+        Vector<MenuElement> tmp = new Vector<MenuElement>();
         int c = getComponentCount();
         int i;
         Component m;
@@ -1502,12 +1497,12 @@
         for(i=0 ; i < c ; i++) {
             m = getComponent(i);
             if(m instanceof MenuElement)
-                tmp.addElement(m);
+                tmp.addElement((MenuElement) m);
         }
 
         result = new MenuElement[tmp.size()];
         for(i=0,c=tmp.size() ; i < c ; i++)
-            result[i] = (MenuElement) tmp.elementAt(i);
+            result[i] = tmp.elementAt(i);
         return result;
     }