src/solaris/classes/sun/awt/X11/XListPeer.java

Print this page
rev 9830 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by: darcy, prr

@@ -68,11 +68,11 @@
     XVerticalScrollbar       vsb;
     XHorizontalScrollbar     hsb;
     ListPainter painter;
 
     // TODO: ick - Vector?
-    Vector                      items;
+    Vector<String>              items;
     boolean                     multipleSelections;
     int                         active = NONE;
 
     // Holds the array of the indexes of the elements which is selected
     // This array should be kept sorted, low to high.

@@ -137,11 +137,11 @@
      */
     public void preInit(XCreateWindowParams params) {
         super.preInit(params);
 
         // Stuff that must be initialized before layout() is called
-        items = new Vector();
+        items = new Vector<>();
         createVerScrollbar();
         createHorScrollbar();
 
         painter = new ListPainter();
 

@@ -279,22 +279,22 @@
     int maxLength() {
         FontMetrics fm = getFontMetrics(getFont());
         int m = 0;
         int end = items.size();
         for(int i = 0 ; i < end ; i++) {
-            int l = fm.stringWidth(((String)items.elementAt(i)));
+            int l = fm.stringWidth(items.elementAt(i));
             m = Math.max(m, l);
         }
         return m;
     }
 
     /**
      * Calculates the width of item's label
      */
     int getItemWidth(int i) {
         FontMetrics fm = getFontMetrics(getFont());
-        return fm.stringWidth((String)items.elementAt(i));
+        return fm.stringWidth(items.elementAt(i));
     }
 
     /**
      * return the on-screen width of the given string "str"
      */

@@ -657,11 +657,11 @@
                                      mouseEvent.getY()-(height-SCROLLBAR_WIDTH));
             } else if ( ( currentIndex >= 0 ) && ( clickCount >= 2 ) &&
                         ( clickCount % 2 == 0 ) ) {
                 postEvent(new ActionEvent(target,
                                           ActionEvent.ACTION_PERFORMED,
-                                          (String)items.elementAt(currentIndex),
+                                          items.elementAt(currentIndex),
                                           mouseEvent.getWhen(),
                                           mouseEvent.getModifiers()));  // No ext mods
             } else if (active == WINDOW) {
                 // See 6243382 for more information
                 trackMouseReleasedScroll();

@@ -984,11 +984,11 @@
               // say: "AWT also generates an action event when the user presses
               // the return key while an item in the list is selected."
               if (selected.length > 0) {
                   postEvent(new ActionEvent((List)target,
                                             ActionEvent.ACTION_PERFORMED,
-                                            (String)items.elementAt(getFocusIndex()),
+                                            items.elementAt(getFocusIndex()),
                                             e.getWhen(),
                                             e.getModifiers()));  // ActionEvent doesn't have
                   // extended modifiers.
               }
               break;

@@ -1341,11 +1341,11 @@
     /**
      * clear
      */
     public void clear() {
         selected = new int[0];
-        items = new Vector();
+        items = new Vector<>();
         currentIndex = -1;
         // Fixed 6291736: ITEM_STATE_CHANGED triggered after List.removeAll(), XToolkit
         // We should update 'focusIndex' variable more carefully
         setFocusIndex(-1);
         vsb.setValue(0);

@@ -1924,11 +1924,11 @@
                     } else if (isSelected(index)) {
                         g.setColor(getListBackground());
                     } else {
                         g.setColor(getListForeground());
                     }
-                    String str = (String)items.elementAt(index);
+                    String str = items.elementAt(index);
                     g.drawString(str, x - hsb.getValue(), y + fontAscent);
                 } else {
                     // Clear the remaining area around the item - focus area and the rest of border
                     g.setClip(x, y, listWidth, h);
                     g.setColor(getListBackground());