src/share/classes/sun/swing/FilePane.java

Print this page

        

@@ -238,11 +238,11 @@
             } else if (source instanceof JTable) {
                 repaintTableSelection((JTable)source);
             }
         }
 
-        private void repaintListSelection(JList list) {
+        private void repaintListSelection(JList<?> list) {
             int[] indices = list.getSelectedIndices();
             for (int i : indices) {
                 Rectangle bounds = list.getCellBounds(i, i);
                 list.repaint(bounds);
             }

@@ -270,11 +270,11 @@
     private boolean listViewWindowsStyle;
     private boolean readOnly;
     private boolean fullRowSelection = false;
 
     private ListSelectionModel listSelectionModel;
-    private JList list;
+    private JList<?> list;
     private JTable detailsTable;
 
     private static final int COLUMN_FILENAME = 0;
 
     // Provides a way to recognize a newly created folder, so it can

@@ -330,11 +330,11 @@
                 createdViewPanel = fileChooserUIAccessor.createList();
                 if (createdViewPanel == null) {
                     createdViewPanel = createList();
                 }
 
-                list = (JList) findChildComponent(createdViewPanel, JList.class);
+                list = findChildComponent(createdViewPanel, JList.class);
                 if (listSelectionModel == null) {
                     listSelectionModel = list.getSelectionModel();
                     if (detailsTable != null) {
                         detailsTable.setSelectionModel(listSelectionModel);
                     }

@@ -351,11 +351,11 @@
                 createdViewPanel = fileChooserUIAccessor.createDetailsView();
                 if (createdViewPanel == null) {
                     createdViewPanel = createDetailsView();
                 }
 
-                detailsTable = (JTable) findChildComponent(createdViewPanel, JTable.class);
+                detailsTable = findChildComponent(createdViewPanel, JTable.class);
                 detailsTable.setRowHeight(Math.max(detailsTable.getFont().getSize() + 4, 16 + 1));
                 if (listSelectionModel != null) {
                     detailsTable.setSelectionModel(listSelectionModel);
                 }
             }

@@ -567,11 +567,11 @@
             }
         }
     }
 
 
-    private void updateListRowCount(JList list) {
+    private void updateListRowCount(JList<?> list) {
         if (smallIconsView) {
             list.setVisibleRowCount(getModel().getSize() / 3);
         } else {
             list.setVisibleRowCount(-1);
         }

@@ -582,11 +582,11 @@
         final JFileChooser fileChooser = getFileChooser();
 
         @SuppressWarnings("serial") // anonymous class
         final JList<Object> list = new JList<Object>() {
             public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
-                ListModel model = getModel();
+                ListModel<?> model = getModel();
                 int max = model.getSize();
                 if (prefix == null || startIndex < 0 || startIndex >= max) {
                     throw new IllegalArgumentException();
                 }
                 // start search from the next element before/after the selected element

@@ -916,11 +916,11 @@
             setModelWrapper(new SorterModelWrapper());
         }
 
         public void updateComparators(ShellFolderColumnInfo [] columns) {
             for (int i = 0; i < columns.length; i++) {
-                Comparator c = columns[i].getComparator();
+                Comparator<?> c = columns[i].getComparator();
                 if (c != null) {
                     c = new DirectoriesFirstComparatorWrapper(i, c);
                 }
                 setComparator(i, c);
             }

@@ -967,16 +967,17 @@
     /**
      * This class sorts directories before files, comparing directory to
      * directory and file to file using the wrapped comparator.
      */
     private class DirectoriesFirstComparatorWrapper implements Comparator<File> {
-        private Comparator comparator;
+        private Comparator<Object> comparator;
         private int column;
 
-        public DirectoriesFirstComparatorWrapper(int column, Comparator comparator) {
+        @SuppressWarnings("unchecked")
+        public DirectoriesFirstComparatorWrapper(int column, Comparator<?> comparator) {
             this.column = column;
-            this.comparator = comparator;
+            this.comparator = (Comparator<Object>)comparator;
         }
 
         public int compare(File f1, File f2) {
             if (f1 != null && f2 != null) {
                 boolean traversable1 = getFileChooser().isTraversable(f1);

@@ -1490,11 +1491,11 @@
     }
 
     @SuppressWarnings("serial") // JDK-implementation class
     protected class FileRenderer extends DefaultListCellRenderer  {
 
-        public Component getListCellRendererComponent(JList list, Object value,
+        public Component getListCellRendererComponent(JList<?> list, Object value,
                                                       int index, boolean isSelected,
                                                       boolean cellHasFocus) {
 
             if (listViewWindowsStyle && !list.isFocusOwner()) {
                 isSelected = false;

@@ -1966,18 +1967,18 @@
      */
     protected File getDirectory() {
         return fileChooserUIAccessor.getDirectory();
     }
 
-    private Component findChildComponent(Container container, Class cls) {
+    private <T> T findChildComponent(Container container, Class<T> cls) {
         int n = container.getComponentCount();
         for (int i = 0; i < n; i++) {
             Component comp = container.getComponent(i);
             if (cls.isInstance(comp)) {
-                return comp;
+                return cls.cast(comp);
             } else if (comp instanceof Container) {
-                Component c = findChildComponent((Container)comp, cls);
+                T c = findChildComponent((Container)comp, cls);
                 if (c != null) {
                     return c;
                 }
             }
         }

@@ -2027,9 +2028,9 @@
         public boolean isDirectorySelected();
         public File getDirectory();
         public Action getApproveSelectionAction();
         public Action getChangeToParentDirectoryAction();
         public Action getNewFolderAction();
-        public MouseListener createDoubleClickListener(JList list);
+        public MouseListener createDoubleClickListener(JList<?> list);
         public ListSelectionListener createListSelectionListener();
     }
 }