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

Print this page
rev 9717 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by:

@@ -53,14 +53,14 @@
     private final int TEXT_SPACE;   // Space between the edge of an item and
                                     // the text
 
     private final int SCROLLBAR_WIDTH;  // Width of a scrollbar
 
-    private java.util.List items;        // List of items
+    private java.util.List<String> items;        // List of items
 
     // TODO: maybe this would be better as a simple int[]
-    private java.util.List selected;     // List of selected items
+    private java.util.List<Integer> selected;     // List of selected items
     private boolean multiSelect;         // Can multiple items be selected
                                          // at once?
     private int focusedIndex;
 
     private int maxVisItems;             // # items visible without a vsb

@@ -98,12 +98,12 @@
                       int BORDER,
                       int SCROLLBAR) {
         this.peer = peer;
         this.colors = colors;
         this.multiSelect = multiSelect;
-        items = new ArrayList(initialSize);
-        selected = new ArrayList(1);
+        items = new ArrayList<>(initialSize);
+        selected = new ArrayList<>(1);
         selected.add(Integer.valueOf(-1));
 
         this.maxVisItems = maxVisItems;
         if (scrollVert) {
             vsb = new XVerticalScrollbar(this);

@@ -188,11 +188,11 @@
 
     /* docs */
     /* if called for multiselect, return -1 */
     public int getSelectedIndex() {
         if (!multiSelect) {
-            Integer val = (Integer)selected.get(0);
+            Integer val = selected.get(0);
             return val.intValue();
         }
         return -1;
     }
 

@@ -215,11 +215,11 @@
     public int getItemCount() {
         return items.size();
     }
 
     public String getItem(int index) {
-        return (String) items.get(index);
+        return items.get(index);
     }
 
     /**********************************************************************/
     /* GUI-related methods                                                */
     /**********************************************************************/

@@ -574,13 +574,13 @@
         g.drawString(string, x + TEXT_SPACE, y + (height + fm.getMaxAscent() - fm.getMaxDescent())/2);
         //g.clipRect(clip.x, clip.y, clip.width, clip.height);
     }
 
     boolean isItemSelected(int index) {
-        Iterator itr = selected.iterator();
+        Iterator<Integer> itr = selected.iterator();
         while (itr.hasNext()) {
-            Integer val = (Integer)itr.next();
+            Integer val = itr.next();
             if (val.intValue() == index) {
                 return true;
             }
         }
         return false;