changeset 614:85f6a6d7d812

6727661: Code improvement and warnings removing from the swing/plaf packages Summary: Removed unnecessary castings and other warnings Reviewed-by: alexp Contributed-by: Florian Brunner <fbrunnerlist@gmx.ch>
author rupashka
date Fri, 25 Jul 2008 17:50:36 +0400
parents a2266940ae33
children 86b43f44bcc4
files src/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java src/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java src/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java src/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java src/share/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java src/share/classes/javax/swing/plaf/basic/BasicButtonListener.java src/share/classes/javax/swing/plaf/basic/BasicButtonUI.java src/share/classes/javax/swing/plaf/basic/BasicComboBoxEditor.java src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java src/share/classes/javax/swing/plaf/basic/BasicGraphicsUtils.java src/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java src/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java src/share/classes/javax/swing/plaf/basic/BasicMenuUI.java src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java src/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java src/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java src/share/classes/javax/swing/plaf/basic/BasicTextUI.java src/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java src/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java src/share/classes/javax/swing/plaf/basic/DragRecognitionSupport.java src/share/classes/javax/swing/plaf/basic/LazyActionMap.java src/share/classes/javax/swing/plaf/metal/DefaultMetalTheme.java src/share/classes/javax/swing/plaf/metal/MetalBumps.java src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java src/share/classes/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java src/share/classes/javax/swing/plaf/metal/MetalToolBarUI.java src/share/classes/javax/swing/plaf/synth/DefaultSynthStyleFactory.java src/share/classes/javax/swing/plaf/synth/ImagePainter.java src/share/classes/javax/swing/plaf/synth/Region.java src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java src/share/classes/javax/swing/plaf/synth/SynthContext.java src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java src/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java src/share/classes/javax/swing/plaf/synth/SynthParser.java src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java src/share/classes/javax/swing/plaf/synth/SynthStyle.java src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java src/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
diffstat 54 files changed, 378 insertions(+), 426 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java	Fri Jul 25 17:50:36 2008 +0400
@@ -49,8 +49,7 @@
     /**
      * ReferenceQueue of unreferenced WeakPCLs.
      */
-    private static ReferenceQueue queue;
-
+    private static ReferenceQueue<DesktopProperty> queue;
 
     /**
      * PropertyChangeListener attached to the Toolkit.
@@ -76,7 +75,7 @@
 
 
     static {
-        queue = new ReferenceQueue();
+        queue = new ReferenceQueue<DesktopProperty>();
     }
 
     /**
@@ -117,8 +116,8 @@
             XPStyle.invalidateStyle();
         }
         Frame appFrames[] = Frame.getFrames();
-        for (int j=0; j < appFrames.length; j++) {
-            updateWindowUI(appFrames[j]);
+        for (Frame appFrame : appFrames) {
+            updateWindowUI(appFrame);
         }
     }
 
@@ -128,8 +127,8 @@
     private static void updateWindowUI(Window window) {
         SwingUtilities.updateComponentTreeUI(window);
         Window ownedWins[] = window.getOwnedWindows();
-        for (int i=0; i < ownedWins.length; i++) {
-            updateWindowUI(ownedWins[i]);
+        for (Window ownedWin : ownedWins) {
+            updateWindowUI(ownedWin);
         }
     }
 
@@ -270,13 +269,13 @@
      * is handled via a WeakReference so as not to pin down the
      * DesktopProperty.
      */
-    private static class WeakPCL extends WeakReference
+    private static class WeakPCL extends WeakReference<DesktopProperty>
                                implements PropertyChangeListener {
         private Toolkit kit;
         private String key;
         private LookAndFeel laf;
 
-        WeakPCL(Object target, Toolkit kit, String key, LookAndFeel laf) {
+        WeakPCL(DesktopProperty target, Toolkit kit, String key, LookAndFeel laf) {
             super(target, queue);
             this.kit = kit;
             this.key = key;
@@ -284,7 +283,7 @@
         }
 
         public void propertyChange(PropertyChangeEvent pce) {
-            DesktopProperty property = (DesktopProperty)get();
+            DesktopProperty property = get();
 
             if (property == null || laf != UIManager.getLookAndFeel()) {
                 // The property was GC'ed, we're no longer interested in
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java	Fri Jul 25 17:50:36 2008 +0400
@@ -96,7 +96,7 @@
             }
         } catch (PropertyVetoException e) {}
         if (f != currentFrame) {
-            currentFrameRef = new WeakReference(f);
+            currentFrameRef = new WeakReference<JInternalFrame>(f);
         }
     }
 
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -983,7 +983,7 @@
                 } else if (s.equals("componentOrientation")) {
                     ComponentOrientation o = (ComponentOrientation)e.getNewValue();
                     JFileChooser cc = (JFileChooser)e.getSource();
-                    if (o != (ComponentOrientation)e.getOldValue()) {
+                    if (o != e.getOldValue()) {
                         cc.applyComponentOrientation(o);
                     }
                 } else if (s.equals("ancestor")) {
@@ -1123,7 +1123,7 @@
      * Data model for a type-face selection combo-box.
      */
     protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
-        Vector directories = new Vector();
+        Vector<File> directories = new Vector<File>();
         int[] depths = null;
         File selectedDirectory = null;
         JFileChooser chooser = getFileChooser();
@@ -1162,7 +1162,7 @@
             // Get the canonical (full) path. This has the side
             // benefit of removing extraneous chars from the path,
             // for example /foo/bar/ becomes /foo/bar
-            File canonical = null;
+            File canonical;
             try {
                 canonical = directory.getCanonicalFile();
             } catch (IOException e) {
@@ -1175,7 +1175,7 @@
                 File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
                                          : canonical;
                 File f = sf;
-                Vector path = new Vector(10);
+                Vector<File> path = new Vector<File>(10);
                 do {
                     path.addElement(f);
                 } while ((f = f.getParentFile()) != null);
@@ -1183,7 +1183,7 @@
                 int pathCount = path.size();
                 // Insert chain at appropriate place in vector
                 for (int i = 0; i < pathCount; i++) {
-                    f = (File)path.get(i);
+                    f = path.get(i);
                     if (directories.contains(f)) {
                         int topIndex = directories.indexOf(f);
                         for (int j = i-1; j >= 0; j--) {
@@ -1202,12 +1202,12 @@
         private void calculateDepths() {
             depths = new int[directories.size()];
             for (int i = 0; i < depths.length; i++) {
-                File dir = (File)directories.get(i);
+                File dir = directories.get(i);
                 File parent = dir.getParentFile();
                 depths[i] = 0;
                 if (parent != null) {
                     for (int j = i-1; j >= 0; j--) {
-                        if (parent.equals((File)directories.get(j))) {
+                        if (parent.equals(directories.get(j))) {
                             depths[i] = depths[j] + 1;
                             break;
                         }
@@ -1306,8 +1306,8 @@
             FileFilter currentFilter = getFileChooser().getFileFilter();
             boolean found = false;
             if(currentFilter != null) {
-                for(int i=0; i < filters.length; i++) {
-                    if(filters[i] == currentFilter) {
+                for (FileFilter filter : filters) {
+                    if (filter == currentFilter) {
                         found = true;
                     }
                 }
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java	Fri Jul 25 17:50:36 2008 +0400
@@ -258,8 +258,8 @@
                     g.fillRect(0, 0, w, h);
                 }
                 Icon icon = getIcon();
-                int iconWidth = 0;
-                int iconHeight = 0;
+                int iconWidth;
+                int iconHeight;
                 if (icon != null &&
                     (iconWidth = icon.getIconWidth()) > 0 &&
                     (iconHeight = icon.getIconHeight()) > 0) {
@@ -304,18 +304,18 @@
     }
 
     protected void addSystemMenuItems(JPopupMenu menu) {
-        JMenuItem mi = (JMenuItem)menu.add(restoreAction);
+        JMenuItem mi = menu.add(restoreAction);
         mi.setMnemonic('R');
-        mi = (JMenuItem)menu.add(moveAction);
+        mi = menu.add(moveAction);
         mi.setMnemonic('M');
-        mi = (JMenuItem)menu.add(sizeAction);
+        mi = menu.add(sizeAction);
         mi.setMnemonic('S');
-        mi = (JMenuItem)menu.add(iconifyAction);
+        mi = menu.add(iconifyAction);
         mi.setMnemonic('n');
-        mi = (JMenuItem)menu.add(maximizeAction);
+        mi = menu.add(maximizeAction);
         mi.setMnemonic('x');
         systemPopupMenu.add(new JSeparator());
-        mi = (JMenuItem)menu.add(closeAction);
+        mi = menu.add(closeAction);
         mi.setMnemonic('C');
     }
 
@@ -441,7 +441,7 @@
 
     public class WindowsPropertyChangeHandler extends PropertyChangeHandler {
         public void propertyChange(PropertyChangeEvent evt) {
-            String prop = (String)evt.getPropertyName();
+            String prop = evt.getPropertyName();
 
             // Update the internal frame icon for the system menu.
             if (JInternalFrame.FRAME_ICON_PROPERTY.equals(prop) &&
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -369,21 +369,21 @@
      */
     private static class Grid {
         private static final int BUFFER_SIZE = 64;
-        private static HashMap map;
+        private static HashMap<String, WeakReference<Grid>> map;
 
         private BufferedImage image;
 
         static {
-            map = new HashMap();
+            map = new HashMap<String, WeakReference<Grid>>();
         }
 
         public static Grid getGrid(Color fg, Color bg) {
             String key = fg.getRGB() + " " + bg.getRGB();
-            WeakReference ref = (WeakReference)map.get(key);
-            Grid grid = (ref == null) ? null : (Grid)ref.get();
+            WeakReference<Grid> ref = map.get(key);
+            Grid grid = (ref == null) ? null : ref.get();
             if (grid == null) {
                 grid = new Grid(fg, bg);
-                map.put(key, new WeakReference(grid));
+                map.put(key, new WeakReference<Grid>(grid));
             }
             return grid;
         }
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -53,13 +53,13 @@
      * Keys to use for forward focus traversal when the JComponent is
      * managing focus.
      */
-    private static Set managingFocusForwardTraversalKeys;
+    private static Set<KeyStroke> managingFocusForwardTraversalKeys;
 
     /**
      * Keys to use for backward focus traversal when the JComponent is
      * managing focus.
      */
-    private static Set managingFocusBackwardTraversalKeys;
+    private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
 
     private boolean contentOpaque = true;
 
@@ -69,13 +69,13 @@
 
         // focus forward traversal key
         if (managingFocusForwardTraversalKeys==null) {
-            managingFocusForwardTraversalKeys = new HashSet();
+            managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
             managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
         }
         tabPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys);
         // focus backward traversal key
         if (managingFocusBackwardTraversalKeys==null) {
-            managingFocusBackwardTraversalKeys = new HashSet();
+            managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
             managingFocusBackwardTraversalKeys.add( KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
         }
         tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys);
--- a/src/share/classes/javax/swing/plaf/basic/BasicButtonListener.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicButtonListener.java	Fri Jul 25 17:50:36 2008 +0400
@@ -165,7 +165,7 @@
             JRootPane root = b.getRootPane();
             if (root != null) {
                BasicButtonUI ui = (BasicButtonUI)BasicLookAndFeel.getUIOfType(
-                         ((AbstractButton)b).getUI(), BasicButtonUI.class);
+                         b.getUI(), BasicButtonUI.class);
                if (ui != null && DefaultLookup.getBoolean(b, ui,
                                    ui.getPropertyPrefix() +
                                    "defaultButtonFollowsFocus", true)) {
@@ -185,7 +185,7 @@
            JButton initialDefault = (JButton)root.getClientProperty("initialDefaultButton");
            if (b != initialDefault) {
                BasicButtonUI ui = (BasicButtonUI)BasicLookAndFeel.getUIOfType(
-                         ((AbstractButton)b).getUI(), BasicButtonUI.class);
+                         b.getUI(), BasicButtonUI.class);
                if (ui != null && DefaultLookup.getBoolean(b, ui,
                                    ui.getPropertyPrefix() +
                                    "defaultButtonFollowsFocus", true)) {
@@ -239,7 +239,7 @@
              }
           }
        }
-    };
+    }
 
     public void mouseReleased(MouseEvent e) {
         if (SwingUtilities.isLeftMouseButton(e)) {
@@ -253,7 +253,7 @@
             model.setPressed(false);
             model.setArmed(false);
         }
-    };
+    }
 
     public void mouseEntered(MouseEvent e) {
         AbstractButton b = (AbstractButton) e.getSource();
@@ -263,7 +263,7 @@
         }
         if (model.isPressed())
                 model.setArmed(true);
-    };
+    }
 
     public void mouseExited(MouseEvent e) {
         AbstractButton b = (AbstractButton) e.getSource();
@@ -272,7 +272,7 @@
             model.setRollover(false);
         }
         model.setArmed(false);
-    };
+    }
 
 
     /**
--- a/src/share/classes/javax/swing/plaf/basic/BasicButtonUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicButtonUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -237,7 +237,7 @@
 
             /* the fallback icon should be based on the selected state */
             if (model.isSelected()) {
-                selectedIcon = (Icon) b.getSelectedIcon();
+                selectedIcon = b.getSelectedIcon();
                 if (selectedIcon != null) {
                     icon = selectedIcon;
                 }
@@ -245,31 +245,31 @@
 
             if(!model.isEnabled()) {
                 if(model.isSelected()) {
-                   tmpIcon = (Icon) b.getDisabledSelectedIcon();
+                   tmpIcon = b.getDisabledSelectedIcon();
                    if (tmpIcon == null) {
                        tmpIcon = selectedIcon;
                    }
                 }
 
                 if (tmpIcon == null) {
-                    tmpIcon = (Icon) b.getDisabledIcon();
+                    tmpIcon = b.getDisabledIcon();
                 }
             } else if(model.isPressed() && model.isArmed()) {
-                tmpIcon = (Icon) b.getPressedIcon();
+                tmpIcon = b.getPressedIcon();
                 if(tmpIcon != null) {
                     // revert back to 0 offset
                     clearTextShiftOffset();
                 }
             } else if(b.isRolloverEnabled() && model.isRollover()) {
                 if(model.isSelected()) {
-                   tmpIcon = (Icon) b.getRolloverSelectedIcon();
+                   tmpIcon = b.getRolloverSelectedIcon();
                    if (tmpIcon == null) {
                        tmpIcon = selectedIcon;
                    }
                 }
 
                 if (tmpIcon == null) {
-                    tmpIcon = (Icon) b.getRolloverIcon();
+                    tmpIcon = b.getRolloverIcon();
                 }
             }
 
@@ -451,9 +451,9 @@
         MouseMotionListener[] listeners = b.getMouseMotionListeners();
 
         if (listeners != null) {
-            for (int counter = 0; counter < listeners.length; counter++) {
-                if (listeners[counter] instanceof BasicButtonListener) {
-                    return (BasicButtonListener)listeners[counter];
+            for (MouseMotionListener listener : listeners) {
+                if (listener instanceof BasicButtonListener) {
+                    return (BasicButtonListener) listener;
                 }
             }
         }
--- a/src/share/classes/javax/swing/plaf/basic/BasicComboBoxEditor.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicComboBoxEditor.java	Fri Jul 25 17:50:36 2008 +0400
@@ -92,7 +92,7 @@
                 return oldValue;
             } else {
                 // Must take the value from the editor and get the value and cast it to the new type.
-                Class cls = oldValue.getClass();
+                Class<?> cls = oldValue.getClass();
                 try {
                     Method method = cls.getMethod("valueOf", new Class[]{String.class});
                     newValue = method.invoke(oldValue, new Object[] { editor.getText()});
--- a/src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java	Fri Jul 25 17:50:36 2008 +0400
@@ -43,10 +43,10 @@
 
     private JFileChooser filechooser = null;
     // PENDING(jeff) pick the size more sensibly
-    private Vector fileCache = new Vector(50);
+    private Vector<File> fileCache = new Vector<File>(50);
     private LoadFilesThread loadThread = null;
-    private Vector files = null;
-    private Vector directories = null;
+    private Vector<File> files = null;
+    private Vector<File> directories = null;
     private int fetchID = 0;
 
     private PropertyChangeSupport changeSupport;
@@ -106,14 +106,14 @@
             if (files != null) {
                 return files;
             }
-            files = new Vector();
-            directories = new Vector();
+            files = new Vector<File>();
+            directories = new Vector<File>();
             directories.addElement(filechooser.getFileSystemView().createFileObject(
                 filechooser.getCurrentDirectory(), "..")
             );
 
             for (int i = 0; i < getSize(); i++) {
-                File f = (File)fileCache.get(i);
+                File f = fileCache.get(i);
                 if (filechooser.isTraversable(f)) {
                     directories.add(f);
                 } else {
@@ -215,7 +215,7 @@
     class LoadFilesThread extends Thread {
         File currentDirectory = null;
         int fid;
-        Vector runnables = new Vector(10);
+        Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
 
         public LoadFilesThread(File currentDirectory, int fid) {
             super("Basic L&F File Loading Thread");
@@ -223,7 +223,7 @@
             this.fid = fid;
         }
 
-        private void invokeLater(Runnable runnable) {
+        private void invokeLater(DoChangeContents runnable) {
             runnables.addElement(runnable);
             SwingUtilities.invokeLater(runnable);
         }
@@ -245,9 +245,9 @@
             }
 
             // run through the file list, add directories and selectable files to fileCache
-            for (int i = 0; i < list.length; i++) {
-                if(filechooser.accept(list[i])) {
-                    acceptsList.addElement(list[i]);
+            for (File file : list) {
+                if (filechooser.accept(file)) {
+                    acceptsList.addElement(file);
                 }
             }
 
@@ -258,11 +258,11 @@
             // First sort alphabetically by filename
             sort(acceptsList);
 
-            Vector newDirectories = new Vector(50);
-            Vector newFiles = new Vector();
+            Vector<File> newDirectories = new Vector<File>(50);
+            Vector<File> newFiles = new Vector<File>();
             // run through list grabbing directories in chunks of ten
             for(int i = 0; i < acceptsList.size(); i++) {
-                File f = (File) acceptsList.elementAt(i);
+                File f = acceptsList.elementAt(i);
                 boolean isTraversable = filechooser.isTraversable(f);
                 if (isTraversable) {
                     newDirectories.addElement(f);
@@ -274,7 +274,7 @@
                 }
             }
 
-            Vector newFileCache = new Vector(newDirectories);
+            Vector<File> newFileCache = new Vector<File>(newDirectories);
             newFileCache.addAll(newFiles);
 
             int newSize = newFileCache.size();
@@ -320,7 +320,7 @@
                     if(isInterrupted()) {
                         return;
                     }
-                    invokeLater(new DoChangeContents(null, 0, new Vector(fileCache.subList(start, end)),
+                    invokeLater(new DoChangeContents(null, 0, new Vector<File>(fileCache.subList(start, end)),
                                                      start, fid));
                     newFileCache = null;
                 }
@@ -334,9 +334,9 @@
         }
 
 
-        public void cancelRunnables(Vector runnables) {
-            for(int i = 0; i < runnables.size(); i++) {
-                ((DoChangeContents)runnables.elementAt(i)).cancel();
+        public void cancelRunnables(Vector<DoChangeContents> runnables) {
+            for (DoChangeContents runnable : runnables) {
+                runnable.cancel();
             }
         }
 
@@ -449,15 +449,14 @@
 
 
     class DoChangeContents implements Runnable {
-        private List addFiles;
-        private List remFiles;
+        private List<File> addFiles;
+        private List<File> remFiles;
         private boolean doFire = true;
         private int fid;
         private int addStart = 0;
         private int remStart = 0;
-        private int change;
 
-        public DoChangeContents(List addFiles, int addStart, List remFiles, int remStart, int fid) {
+        public DoChangeContents(List<File> addFiles, int addStart, List<File> remFiles, int remStart, int fid) {
             this.addFiles = addFiles;
             this.addStart = addStart;
             this.remFiles = remFiles;
--- a/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -159,9 +159,9 @@
     }
 
     public void uninstallUI(JComponent c) {
-        uninstallListeners((JFileChooser) filechooser);
-        uninstallComponents((JFileChooser) filechooser);
-        uninstallDefaults((JFileChooser) filechooser);
+        uninstallListeners(filechooser);
+        uninstallComponents(filechooser);
+        uninstallDefaults(filechooser);
 
         if(accessoryPanel != null) {
             accessoryPanel.removeAll();
@@ -506,9 +506,9 @@
                             setDirectorySelected(true);
                             setDirectory(((File)objects[0]));
                         } else {
-                            ArrayList fList = new ArrayList(objects.length);
-                            for (int i = 0; i < objects.length; i++) {
-                                File f = (File)objects[i];
+                            ArrayList<File> fList = new ArrayList<File>(objects.length);
+                            for (Object object : objects) {
+                                File f = (File) object;
                                 boolean isDir = f.isDirectory();
                                 if ((chooser.isFileSelectionEnabled() && !isDir)
                                     || (chooser.isDirectorySelectionEnabled()
@@ -518,7 +518,7 @@
                                 }
                             }
                             if (fList.size() > 0) {
-                                files = (File[])fList.toArray(new File[fList.size()]);
+                                files = fList.toArray(new File[fList.size()]);
                             }
                             setDirectorySelected(false);
                         }
@@ -853,7 +853,7 @@
                 }
 
                 if (chooser.isMultiSelectionEnabled() && filename.startsWith("\"")) {
-                    ArrayList fList = new ArrayList();
+                    ArrayList<File> fList = new ArrayList<File>();
 
                     filename = filename.substring(1);
                     if (filename.endsWith("\"")) {
@@ -889,7 +889,7 @@
                         fList.add(file);
                     } while (filename.length() > 0);
                     if (fList.size() > 0) {
-                        selectedFiles = (File[])fList.toArray(new File[fList.size()]);
+                        selectedFiles = fList.toArray(new File[fList.size()]);
                     }
                     resetGlobFilter();
                 } else {
@@ -1213,7 +1213,7 @@
         }
 
         public Icon getCachedIcon(File f) {
-            return (Icon) iconCache.get(f);
+            return iconCache.get(f);
         }
 
         public void cacheIcon(File f, Icon i) {
@@ -1296,8 +1296,7 @@
 
             htmlBuf.append("<html>\n<body>\n<ul>\n");
 
-            for (int i = 0; i < values.length; i++) {
-                Object obj = values[i];
+            for (Object obj : values) {
                 String val = ((obj == null) ? "" : obj.toString());
                 plainBuf.append(val + "\n");
                 htmlBuf.append("  <li>" + val + "\n");
@@ -1337,9 +1336,9 @@
              */
             protected Object getRicherData(DataFlavor flavor) {
                 if (DataFlavor.javaFileListFlavor.equals(flavor)) {
-                    ArrayList files = new ArrayList();
-                    for (int i = 0; i < fileData.length; i++) {
-                        files.add(fileData[i]);
+                    ArrayList<Object> files = new ArrayList<Object>();
+                    for (Object file : this.fileData) {
+                        files.add(file);
                     }
                     return files;
                 }
--- a/src/share/classes/javax/swing/plaf/basic/BasicGraphicsUtils.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicGraphicsUtils.java	Fri Jul 25 17:50:36 2008 +0400
@@ -266,7 +266,7 @@
             return null;
         }
 
-        Icon icon = (Icon) b.getIcon();
+        Icon icon = b.getIcon();
         String text = b.getText();
 
         Font font = b.getFont();
@@ -277,7 +277,7 @@
         Rectangle viewR = new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE);
 
         SwingUtilities.layoutCompoundLabel(
-            (JComponent) b, fm, text, icon,
+            b, fm, text, icon,
             b.getVerticalAlignment(), b.getHorizontalAlignment(),
             b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
             viewR, iconR, textR, (text == null ? 0 : textIconGap)
--- a/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java	Fri Jul 25 17:50:36 2008 +0400
@@ -269,18 +269,18 @@
     }
 
     protected void addSystemMenuItems(JMenu systemMenu) {
-        JMenuItem mi = (JMenuItem)systemMenu.add(restoreAction);
+        JMenuItem mi = systemMenu.add(restoreAction);
         mi.setMnemonic('R');
-        mi = (JMenuItem)systemMenu.add(moveAction);
+        mi = systemMenu.add(moveAction);
         mi.setMnemonic('M');
-        mi = (JMenuItem)systemMenu.add(sizeAction);
+        mi = systemMenu.add(sizeAction);
         mi.setMnemonic('S');
-        mi = (JMenuItem)systemMenu.add(iconifyAction);
+        mi = systemMenu.add(iconifyAction);
         mi.setMnemonic('n');
-        mi = (JMenuItem)systemMenu.add(maximizeAction);
+        mi = systemMenu.add(maximizeAction);
         mi.setMnemonic('x');
         systemMenu.add(new JSeparator());
-        mi = (JMenuItem)systemMenu.add(closeAction);
+        mi = systemMenu.add(closeAction);
         mi.setMnemonic('C');
     }
 
@@ -414,7 +414,7 @@
         // PropertyChangeListener
         //
         public void propertyChange(PropertyChangeEvent evt) {
-            String prop = (String)evt.getPropertyName();
+            String prop = evt.getPropertyName();
 
             if (prop == JInternalFrame.IS_SELECTED_PROPERTY) {
                 repaint();
@@ -429,19 +429,19 @@
             }
 
             if ("closable" == prop) {
-                if ((Boolean)evt.getNewValue() == Boolean.TRUE) {
+                if (evt.getNewValue() == Boolean.TRUE) {
                     add(closeButton);
                 } else {
                     remove(closeButton);
                 }
             } else if ("maximizable" == prop) {
-                if ((Boolean)evt.getNewValue() == Boolean.TRUE) {
+                if (evt.getNewValue() == Boolean.TRUE) {
                     add(maxButton);
                 } else {
                     remove(maxButton);
                 }
             } else if ("iconable" == prop) {
-                if ((Boolean)evt.getNewValue() == Boolean.TRUE) {
+                if (evt.getNewValue() == Boolean.TRUE) {
                     add(iconButton);
                 } else {
                     remove(iconButton);
@@ -781,7 +781,7 @@
             }
         }
         public boolean isFocusTraversable() { return false; }
-        public void requestFocus() {};
+        public void requestFocus() {}
         public AccessibleContext getAccessibleContext() {
             AccessibleContext ac = super.getAccessibleContext();
             if (uiKey != null) {
@@ -790,6 +790,6 @@
             }
             return ac;
         }
-    };  // end NoFocusButton
+    }  // end NoFocusButton
 
 }   // End Title Pane Class
--- a/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -318,7 +318,7 @@
         if (resizing) {
             return;
         }
-        Cursor s = (Cursor)frame.getLastCursor();
+        Cursor s = frame.getLastCursor();
         if (s == null) {
             s = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
         }
@@ -336,13 +336,13 @@
 
 
     public Dimension getPreferredSize(JComponent x)    {
-        if((JComponent)frame == x)
+        if(frame == x)
             return frame.getLayout().preferredLayoutSize(x);
         return new Dimension(100, 100);
     }
 
     public Dimension getMinimumSize(JComponent x)  {
-        if((JComponent)frame == x) {
+        if(frame == x) {
             return frame.getLayout().minimumLayoutSize(x);
         }
         return new Dimension(0, 0);
@@ -1093,7 +1093,7 @@
             updateFrameCursor();
         }
 
-    };    /// End BorderListener Class
+    }    /// End BorderListener Class
 
     protected class ComponentHandler implements ComponentListener {
       // NOTE: This class exists only for backward compatability. All
@@ -1196,7 +1196,6 @@
       }
     }
 
-    private static boolean isDragging = false;
     private class Handler implements ComponentListener, InternalFrameListener,
             LayoutManager, MouseInputListener, PropertyChangeListener,
             WindowFocusListener, SwingConstants {
@@ -1373,9 +1372,6 @@
 
 
         // MouseInputListener
-        private Component mouseEventTarget = null;
-        private Component dragSource = null;
-
         public void mousePressed(MouseEvent e) { }
 
         public void mouseEntered(MouseEvent e) { }
@@ -1392,7 +1388,7 @@
 
         // PropertyChangeListener
         public void propertyChange(PropertyChangeEvent evt) {
-            String prop = (String)evt.getPropertyName();
+            String prop = evt.getPropertyName();
             JInternalFrame f = (JInternalFrame)evt.getSource();
             Object newValue = evt.getNewValue();
             Object oldValue = evt.getOldValue();
--- a/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Fri Jul 25 17:50:36 2008 +0400
@@ -2102,8 +2102,6 @@
      * <code>soundFile</code> passed into this method, it will
      * return <code>null</code>.
      *
-     * @param baseClass    used as the root class/location to get the
-     *                     soundFile from
      * @param soundFile    the name of the audio file to be retrieved
      *                     from disk
      * @return             A byte[] with audio data or null
@@ -2120,9 +2118,9 @@
          * Class.getResourceAsStream just returns raw
          * bytes, which we can convert to a sound.
          */
-        byte[] buffer = (byte[])AccessController.doPrivileged(
-                                                 new PrivilegedAction() {
-                public Object run() {
+        byte[] buffer = AccessController.doPrivileged(
+                                                 new PrivilegedAction<byte[]>() {
+                public byte[] run() {
                     try {
                         InputStream resource = BasicLookAndFeel.this.
                             getClass().getResourceAsStream(soundFile);
@@ -2184,9 +2182,9 @@
                                     UIManager.get("AuditoryCues.playList");
             if (audioStrings != null) {
                 // create a HashSet to help us decide to play or not
-                HashSet audioCues = new HashSet();
-                for (int i = 0; i < audioStrings.length; i++) {
-                    audioCues.add(audioStrings[i]);
+                HashSet<Object> audioCues = new HashSet<Object>();
+                for (Object audioString : audioStrings) {
+                    audioCues.add(audioString);
                 }
                 // get the name of the Action
                 String actionName = (String)audioAction.getValue(Action.NAME);
@@ -2237,7 +2235,7 @@
      * This class contains listener that watches for all the mouse
      * events that can possibly invoke popup on the component
      */
-    class AWTEventHelper implements AWTEventListener,PrivilegedAction {
+    class AWTEventHelper implements AWTEventListener,PrivilegedAction<Object> {
         AWTEventHelper() {
             super();
             AccessController.doPrivileged(this);
--- a/src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -1041,15 +1041,15 @@
             Icon icon;
             ButtonModel model = li.mi.getModel();
             if (!model.isEnabled()) {
-                icon = (Icon) li.mi.getDisabledIcon();
+                icon = li.mi.getDisabledIcon();
             } else if (model.isPressed() && model.isArmed()) {
-                icon = (Icon) li.mi.getPressedIcon();
+                icon = li.mi.getPressedIcon();
                 if (icon == null) {
                     // Use default icon
-                    icon = (Icon) li.mi.getIcon();
+                    icon = li.mi.getIcon();
                 }
             } else {
-                icon = (Icon) li.mi.getIcon();
+                icon = li.mi.getIcon();
             }
 
             if (icon != null) {
@@ -1601,7 +1601,7 @@
         for(i=0,j=path.length; i<j ;i++){
             for (int k=0; k<=i; k++)
                 System.out.print("  ");
-            MenuElement me = (MenuElement) path[i];
+            MenuElement me = path[i];
             if(me instanceof JMenuItem)
                 System.out.println(((JMenuItem)me).getText() + ", ");
             else if (me == null)
--- a/src/share/classes/javax/swing/plaf/basic/BasicMenuUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicMenuUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -123,9 +123,9 @@
         InputMap windowInputMap = SwingUtilities.getUIInputMap(
                        menuItem, JComponent.WHEN_IN_FOCUSED_WINDOW);
         if (lastMnemonic != 0 && windowInputMap != null) {
-            for (int i=0; i<shortcutKeys.length; i++) {
+            for (int shortcutKey : shortcutKeys) {
                 windowInputMap.remove(KeyStroke.getKeyStroke
-                                      (lastMnemonic, shortcutKeys[i], false));
+                        (lastMnemonic, shortcutKey, false));
             }
         }
         if (mnemonic != 0) {
@@ -135,10 +135,9 @@
                 SwingUtilities.replaceUIInputMap(menuItem, JComponent.
                                        WHEN_IN_FOCUSED_WINDOW, windowInputMap);
             }
-            for (int i=0; i<shortcutKeys.length; i++) {
+            for (int shortcutKey : shortcutKeys) {
                 windowInputMap.put(KeyStroke.getKeyStroke(mnemonic,
-                                         shortcutKeys[i], false),
-                                   "selectMenu");
+                        shortcutKey, false), "selectMenu");
             }
         }
         lastMnemonic = mnemonic;
@@ -264,14 +263,14 @@
                     if(subElements.length > 0) {
                         me = new MenuElement[4];
                         me[0] = (MenuElement) cnt;
-                        me[1] = (MenuElement) menu;
-                        me[2] = (MenuElement) menu.getPopupMenu();
+                        me[1] = menu;
+                        me[2] = menu.getPopupMenu();
                         me[3] = subElements[0];
                     } else {
                         me = new MenuElement[3];
                         me[0] = (MenuElement)cnt;
                         me[1] = menu;
-                        me[2] = (MenuElement) menu.getPopupMenu();
+                        me[2] = menu.getPopupMenu();
                     }
                     defaultManager.setSelectedPath(me);
                 }
@@ -606,7 +605,7 @@
             MenuSelectionManager manager = e.getMenuSelectionManager();
             if (key == Character.toLowerCase(e.getKeyChar())) {
                 JPopupMenu popupMenu = ((JMenu)menuItem).getPopupMenu();
-                ArrayList newList = new ArrayList(Arrays.asList(path));
+                ArrayList<MenuElement> newList = new ArrayList<MenuElement>(Arrays.asList(path));
                 newList.add(popupMenu);
                 MenuElement subs[] = popupMenu.getSubElements();
                 MenuElement sub =
@@ -614,8 +613,8 @@
                 if(sub != null) {
                     newList.add(sub);
                 }
-                MenuElement newPath[] = new MenuElement[0];;
-                newPath = (MenuElement[]) newList.toArray(newPath);
+                MenuElement newPath[] = new MenuElement[0];
+                newPath = newList.toArray(newPath);
                 manager.setSelectedPath(newPath);
                 e.consume();
             } else if (((JMenu)menuItem).isTopLevelMenu()
--- a/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -109,7 +109,7 @@
 
 
     static {
-        newline = (String)java.security.AccessController.doPrivileged(
+        newline = java.security.AccessController.doPrivileged(
                                 new GetPropertyAction("line.separator"));
         if (newline == null) {
             newline = "\n";
@@ -262,7 +262,7 @@
      * <code>getMinimumOptionPaneSize</code>.
      */
     public Dimension getPreferredSize(JComponent c) {
-        if ((JOptionPane)c == optionPane) {
+        if (c == optionPane) {
             Dimension            ourMin = getMinimumOptionPaneSize();
             LayoutManager        lm = c.getLayout();
 
@@ -366,8 +366,8 @@
 
         } else if (msg instanceof Object[]) {
             Object [] msgs = (Object[]) msg;
-            for (int i = 0; i < msgs.length; i++) {
-                addMessageComponents(container, cons, msgs[i], maxll, false);
+            for (Object o : msgs) {
+                addMessageComponents(container, cons, o, maxll, false);
             }
 
         } else if (msg instanceof Icon) {
@@ -381,7 +381,7 @@
             if (len <= 0) {
                 return;
             }
-            int nl = -1;
+            int nl;
             int nll = 0;
 
             if ((nl = s.indexOf(newline)) >= 0) {
@@ -1320,7 +1320,7 @@
                 else if (changeName == "componentOrientation") {
                     ComponentOrientation o = (ComponentOrientation)e.getNewValue();
                     JOptionPane op = (JOptionPane)e.getSource();
-                    if (o != (ComponentOrientation)e.getOldValue()) {
+                    if (o != e.getOldValue()) {
                         op.applyComponentOrientation(o);
                     }
                 }
@@ -1418,7 +1418,7 @@
         }
 
         JButton createButton() {
-            JButton button = null;
+            JButton button;
 
             if (minimumWidth > 0) {
                 button = new ConstrainedButton(text, minimumWidth);
--- a/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -225,14 +225,14 @@
         return popup;
     }
 
-    static List getPopups() {
+    static List<JPopupMenu> getPopups() {
         MenuSelectionManager msm = MenuSelectionManager.defaultManager();
         MenuElement[] p = msm.getSelectedPath();
 
-        List list = new ArrayList(p.length);
-        for(int i = 0; i < p.length; i++) {
-            if (p[i] instanceof JPopupMenu) {
-                list.add((JPopupMenu)p[i]);
+        List<JPopupMenu> list = new ArrayList<JPopupMenu>(p.length);
+        for (MenuElement element : p) {
+            if (element instanceof JPopupMenu) {
+                list.add((JPopupMenu) element);
             }
         }
         return list;
@@ -290,14 +290,14 @@
                 MenuElement subitem = findEnabledChild(
                         subpopup.getSubElements(), -1, true);
 
-                ArrayList lst = new ArrayList(Arrays.asList(e.getPath()));
+                ArrayList<MenuElement> lst = new ArrayList<MenuElement>(Arrays.asList(e.getPath()));
                 lst.add(menuToOpen);
                 lst.add(subpopup);
                 if (subitem != null) {
                     lst.add(subitem);
                 }
-                MenuElement newPath[] = new MenuElement[0];;
-                newPath = (MenuElement[])lst.toArray(newPath);
+                MenuElement newPath[] = new MenuElement[0];
+                newPath = lst.toArray(newPath);
                 MenuSelectionManager.defaultManager().setSelectedPath(newPath);
                 e.consume();
             }
@@ -345,7 +345,7 @@
             }
 
             if (matches == 0) {
-                ; // no op
+                // no op
             } else if (matches == 1) {
                 // Invoke the menu action
                 JMenuItem item = (JMenuItem)items[firstMatch];
@@ -362,7 +362,7 @@
                 // Select the menu item with the matching mnemonic. If
                 // the same mnemonic has been invoked then select the next
                 // menu item in the cycle.
-                MenuElement newItem = null;
+                MenuElement newItem;
 
                 newItem = items[indexes[(currentIndex + 1) % matches]];
 
@@ -372,7 +372,6 @@
                 manager.setSelectedPath(newPath);
                 e.consume();
             }
-            return;
         }
 
         public void menuKeyReleased(MenuKeyEvent e) {
@@ -625,7 +624,7 @@
             // 4234793: This action should call JPopupMenu.firePopupMenuCanceled but it's
             // a protected method. The real solution could be to make
             // firePopupMenuCanceled public and call it directly.
-            JPopupMenu lastPopup = (JPopupMenu)getLastPopup();
+            JPopupMenu lastPopup = getLastPopup();
             if (lastPopup != null) {
                 lastPopup.putClientProperty("JPopupMenu.firePopupMenuCanceled", Boolean.TRUE);
             }
@@ -703,7 +702,7 @@
 
     static MenuElement findEnabledChild(MenuElement e[], int fromIndex,
                                                 boolean forward) {
-        MenuElement result = null;
+        MenuElement result;
         if (forward) {
             result = nextEnabledChild(e, fromIndex+1, e.length-1);
             if (result == null) result = nextEnabledChild(e, 0, fromIndex-1);
@@ -752,7 +751,7 @@
             // A grab needs to be added
             final Toolkit tk = Toolkit.getDefaultToolkit();
             java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction() {
+                new java.security.PrivilegedAction<Object>() {
                     public Object run() {
                         tk.addAWTEventListener(MouseGrabber.this,
                                 AWTEvent.MOUSE_EVENT_MASK |
@@ -785,7 +784,7 @@
             final Toolkit tk = Toolkit.getDefaultToolkit();
             // The grab should be removed
              java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction() {
+                new java.security.PrivilegedAction<Object>() {
                     public Object run() {
                         tk.removeAWTEventListener(MouseGrabber.this);
                         return null;
@@ -911,10 +910,8 @@
                 // 4234793: This action should call firePopupMenuCanceled but it's
                 // a protected method. The real solution could be to make
                 // firePopupMenuCanceled public and call it directly.
-                List popups = getPopups();
-                Iterator iter = popups.iterator();
-                while (iter.hasNext()) {
-                    JPopupMenu popup = (JPopupMenu) iter.next();
+                List<JPopupMenu> popups = getPopups();
+                for (JPopupMenu popup : popups) {
                     popup.putClientProperty("JPopupMenu.firePopupMenuCanceled", Boolean.TRUE);
                 }
                 MenuSelectionManager.defaultManager().clearSelectedPath();
--- a/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -150,15 +150,15 @@
                 }
             } else if(model.isSelected()) {
                 if(b.isRolloverEnabled() && model.isRollover()) {
-                        altIcon = (Icon) b.getRolloverSelectedIcon();
+                        altIcon = b.getRolloverSelectedIcon();
                         if (altIcon == null) {
-                                altIcon = (Icon) b.getSelectedIcon();
+                                altIcon = b.getSelectedIcon();
                         }
                 } else {
-                        altIcon = (Icon) b.getSelectedIcon();
+                        altIcon = b.getSelectedIcon();
                 }
             } else if(b.isRolloverEnabled() && model.isRollover()) {
-                altIcon = (Icon) b.getRolloverIcon();
+                altIcon = b.getRolloverIcon();
             }
 
             if(altIcon == null) {
@@ -214,7 +214,7 @@
 
         String text = b.getText();
 
-        Icon buttonIcon = (Icon) b.getIcon();
+        Icon buttonIcon = b.getIcon();
         if(buttonIcon == null) {
             buttonIcon = getDefaultIcon();
         }
--- a/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -106,13 +106,13 @@
      * Keys to use for forward focus traversal when the JComponent is
      * managing focus.
      */
-    private static Set managingFocusForwardTraversalKeys;
+    private static Set<KeyStroke> managingFocusForwardTraversalKeys;
 
     /**
      * Keys to use for backward focus traversal when the JComponent is
      * managing focus.
      */
-    private static Set managingFocusBackwardTraversalKeys;
+    private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
 
 
     /**
@@ -370,7 +370,7 @@
 
         // focus forward traversal key
         if (managingFocusForwardTraversalKeys==null) {
-            managingFocusForwardTraversalKeys = new HashSet();
+            managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
             managingFocusForwardTraversalKeys.add(
                 KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
         }
@@ -378,7 +378,7 @@
                                         managingFocusForwardTraversalKeys);
         // focus backward traversal key
         if (managingFocusBackwardTraversalKeys==null) {
-            managingFocusBackwardTraversalKeys = new HashSet();
+            managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
             managingFocusBackwardTraversalKeys.add(
                 KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
         }
@@ -2170,7 +2170,7 @@
             Component focusOn = (direction > 0) ?
                 policy.getComponentAfter(rootAncestor, splitPane) :
                 policy.getComponentBefore(rootAncestor, splitPane);
-            HashSet focusFrom = new HashSet();
+            HashSet<Component> focusFrom = new HashSet<Component>();
             if (splitPane.isAncestorOf(focusOn)) {
                 do {
                     focusFrom.add(focusOn);
@@ -2212,7 +2212,7 @@
         private Component getNextSide(JSplitPane splitPane, Component focus) {
             Component left = splitPane.getLeftComponent();
             Component right = splitPane.getRightComponent();
-            Component next = null;
+            Component next;
             if (focus!=null && SwingUtilities.isDescendingFrom(focus, left) &&
                 right!=null) {
                 next = getFirstAvailableComponent(right);
--- a/src/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -142,9 +142,9 @@
 
     private Component visibleComponent;
     // PENDING(api): See comment for ContainerHandler
-    private Vector htmlViews;
-
-    private Hashtable mnemonicToIndexMap;
+    private Vector<View> htmlViews;
+
+    private Hashtable<Integer, Integer> mnemonicToIndexMap;
 
     /**
      * InputMap used for mnemonics. Only non-null if the JTabbedPane has
@@ -546,7 +546,7 @@
      * Installs the state needed for mnemonics.
      */
     private void initMnemonics() {
-        mnemonicToIndexMap = new Hashtable();
+        mnemonicToIndexMap = new Hashtable<Integer, Integer>();
         mnemonicInputMap = new ComponentInputMapUIResource(tabPane);
         mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(tabPane,
                               JComponent.WHEN_IN_FOCUSED_WINDOW));
@@ -909,10 +909,10 @@
     private static final int CROP_SEGMENT = 12;
 
     private static Polygon createCroppedTabShape(int tabPlacement, Rectangle tabRect, int cropline) {
-        int rlen = 0;
-        int start = 0;
-        int end = 0;
-        int ostart = 0;
+        int rlen;
+        int start;
+        int end;
+        int ostart;
 
         switch(tabPlacement) {
           case LEFT:
@@ -1014,7 +1014,7 @@
             tabPane.putClientProperty("html", v);
         }
 
-        SwingUtilities.layoutCompoundLabel((JComponent) tabPane,
+        SwingUtilities.layoutCompoundLabel(tabPane,
                                            metrics, title, icon,
                                            SwingUtilities.CENTER,
                                            SwingUtilities.CENTER,
@@ -1694,7 +1694,7 @@
      */
     protected View getTextViewForTab(int tabIndex) {
         if (htmlViews != null) {
-            return (View)htmlViews.elementAt(tabIndex);
+            return htmlViews.elementAt(tabIndex);
         }
         return null;
     }
@@ -2230,8 +2230,7 @@
                     if (mnemonic >= 'a' && mnemonic <='z') {
                         mnemonic  -= ('a' - 'A');
                     }
-                    Integer index = (Integer)ui.mnemonicToIndexMap.
-                                 get(Integer.valueOf(mnemonic));
+                    Integer index = ui.mnemonicToIndexMap.get(Integer.valueOf(mnemonic));
                     if (index != null && pane.isEnabledAt(index.intValue())) {
                         pane.setSelectedIndex(index.intValue());
                     }
@@ -2292,8 +2291,7 @@
             for (int i = 0; i < tabPane.getTabCount(); i++) {
                 Component component = tabPane.getComponentAt(i);
                 if (component != null) {
-                    Dimension size = zeroSize;
-                    size = minimum? component.getMinimumSize() :
+                    Dimension size = minimum ? component.getMinimumSize() :
                                 component.getPreferredSize();
 
                     if (size != null) {
@@ -2305,7 +2303,7 @@
             // Add content border insets to minimum size
             width += cWidth;
             height += cHeight;
-            int tabExtent = 0;
+            int tabExtent;
 
             // Calculate how much space the tabs will need, based on the
             // minimum size required to display largest child + content border
@@ -3143,7 +3141,7 @@
             Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
             int fontHeight = metrics.getHeight();
             int selectedIndex = tabPane.getSelectedIndex();
-            int i, j;
+            int i;
             boolean verticalTabRuns = (tabPlacement == LEFT || tabPlacement == RIGHT);
             boolean leftToRight = BasicGraphicsUtils.isLeftToRight(tabPane);
             int x = tabAreaInsets.left;
@@ -3433,10 +3431,10 @@
         }
 
         public String toString() {
-            return new String("viewport.viewSize="+viewport.getViewSize()+"\n"+
+            return "viewport.viewSize=" + viewport.getViewSize() + "\n" +
                               "viewport.viewRectangle="+viewport.getViewRect()+"\n"+
                               "leadingTabIndex="+leadingTabIndex+"\n"+
-                              "tabViewPosition="+tabViewPosition);
+                              "tabViewPosition=" + tabViewPosition;
         }
 
     }
@@ -3788,8 +3786,8 @@
         }
     }
 
-    private Vector createHTMLVector() {
-        Vector htmlViews = new Vector();
+    private Vector<View> createHTMLVector() {
+        Vector<View> htmlViews = new Vector<View>();
         int count = tabPane.getTabCount();
         if (count>0) {
             for (int i=0 ; i<count; i++) {
--- a/src/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -526,16 +526,16 @@
         EditorKit editorKit = getEditorKit(editor);
         if ( editorKit != null
              && editorKit instanceof DefaultEditorKit) {
-            Set storedForwardTraversalKeys = editor.
+            Set<AWTKeyStroke> storedForwardTraversalKeys = editor.
                 getFocusTraversalKeys(KeyboardFocusManager.
                                       FORWARD_TRAVERSAL_KEYS);
-            Set storedBackwardTraversalKeys = editor.
+            Set<AWTKeyStroke> storedBackwardTraversalKeys = editor.
                 getFocusTraversalKeys(KeyboardFocusManager.
                                       BACKWARD_TRAVERSAL_KEYS);
-            Set forwardTraversalKeys =
-                new HashSet(storedForwardTraversalKeys);
-            Set backwardTraversalKeys =
-                new HashSet(storedBackwardTraversalKeys);
+            Set<AWTKeyStroke> forwardTraversalKeys =
+                new HashSet<AWTKeyStroke>(storedForwardTraversalKeys);
+            Set<AWTKeyStroke> backwardTraversalKeys =
+                new HashSet<AWTKeyStroke>(storedBackwardTraversalKeys);
             if (editor.isEditable()) {
                 forwardTraversalKeys.
                     remove(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
@@ -1888,7 +1888,7 @@
          *
          * @param e  The change notification from the currently associated
          *  document.
-         * @see DocumentListener#changeUpdate
+         * @see DocumentListener#changedUpdate(DocumentEvent)
          */
         public final void changedUpdate(DocumentEvent e) {
             Rectangle alloc = (painted) ? getVisibleEditorRect() : null;
@@ -1964,9 +1964,9 @@
                     }
                     try {
                         rootView.setSize(alloc.width, alloc.height);
-                        Enumeration components = constraints.keys();
+                        Enumeration<Component> components = constraints.keys();
                         while (components.hasMoreElements()) {
-                            Component comp = (Component) components.nextElement();
+                            Component comp = components.nextElement();
                             View v = (View) constraints.get(comp);
                             Shape ca = calculateViewPosition(alloc, v);
                             if (ca != null) {
@@ -2009,7 +2009,7 @@
         public void addLayoutComponent(Component comp, Object constraint) {
             if (constraint instanceof View) {
                 if (constraints == null) {
-                    constraints = new Hashtable(7);
+                    constraints = new Hashtable<Component, Object>(7);
                 }
                 constraints.put(comp, constraint);
             }
@@ -2060,7 +2060,7 @@
          * These are View objects for those components that are represented
          * by a View in the View tree.
          */
-        private Hashtable constraints;
+        private Hashtable<Component, Object> constraints;
 
         private boolean i18nView = false;
     }
@@ -2457,8 +2457,7 @@
             JTextComponent c = (JTextComponent)comp;
 
             int pos = modeBetween
-                      ? ((JTextComponent.DropLocation)c.getDropLocation()).getIndex()
-                      : c.getCaretPosition();
+                      ? c.getDropLocation().getIndex() : c.getCaretPosition();
 
             // if we are importing to the same component that we exported from
             // then don't actually do anything if the drop location is inside
--- a/src/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -125,31 +125,31 @@
 
         if(!model.isEnabled()) {
             if(model.isSelected()) {
-               icon = (Icon) b.getDisabledSelectedIcon();
+               icon = b.getDisabledSelectedIcon();
             } else {
-               icon = (Icon) b.getDisabledIcon();
+               icon = b.getDisabledIcon();
             }
         } else if(model.isPressed() && model.isArmed()) {
-            icon = (Icon) b.getPressedIcon();
+            icon = b.getPressedIcon();
             if(icon == null) {
                 // Use selected icon
-                icon = (Icon) b.getSelectedIcon();
+                icon = b.getSelectedIcon();
             }
         } else if(model.isSelected()) {
             if(b.isRolloverEnabled() && model.isRollover()) {
-                icon = (Icon) b.getRolloverSelectedIcon();
+                icon = b.getRolloverSelectedIcon();
                 if (icon == null) {
-                    icon = (Icon) b.getSelectedIcon();
+                    icon = b.getSelectedIcon();
                 }
             } else {
-                icon = (Icon) b.getSelectedIcon();
+                icon = b.getSelectedIcon();
             }
         } else if(b.isRolloverEnabled() && model.isRollover()) {
-            icon = (Icon) b.getRolloverIcon();
+            icon = b.getRolloverIcon();
         }
 
         if(icon == null) {
-            icon = (Icon) b.getIcon();
+            icon = b.getIcon();
         }
 
         icon.paintIcon(b, g, iconRect.x, iconRect.y);
--- a/src/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -83,8 +83,8 @@
     private static Border nonRolloverToggleBorder;
     private boolean rolloverBorders = false;
 
-    private HashMap borderTable = new HashMap();
-    private Hashtable rolloverTable = new Hashtable();
+    private HashMap<AbstractButton, Border> borderTable = new HashMap<AbstractButton, Border>();
+    private Hashtable<AbstractButton, Boolean> rolloverTable = new Hashtable<AbstractButton, Boolean>();
 
 
     /**
@@ -171,7 +171,7 @@
         uninstallKeyboardActions();
 
         // Clear instance vars
-        if (isFloating() == true)
+        if (isFloating())
             setFloating(false, null);
 
         floatingToolBar = null;
@@ -273,9 +273,8 @@
             // Put focus listener on all components in toolbar
             Component[] components = toolBar.getComponents();
 
-            for ( int i = 0; i < components.length; ++i )
-            {
-                components[ i ].addFocusListener( toolBarFocusListener );
+            for (Component component : components) {
+                component.addFocusListener(toolBarFocusListener);
             }
         }
     }
@@ -307,9 +306,8 @@
             // Remove focus listener from all components in toolbar
             Component[] components = toolBar.getComponents();
 
-            for ( int i = 0; i < components.length; ++i )
-            {
-                components[ i ].removeFocusListener( toolBarFocusListener );
+            for (Component component : components) {
+                component.removeFocusListener(toolBarFocusListener);
             }
 
             toolBarFocusListener = null;
@@ -616,10 +614,10 @@
         // Put rollover borders on buttons
         Component[] components = c.getComponents();
 
-        for ( int i = 0; i < components.length; ++i ) {
-            if ( components[ i ] instanceof JComponent ) {
-                ( (JComponent)components[ i ] ).updateUI();
-                setBorderToRollover( components[ i ] );
+        for (Component component : components) {
+            if (component instanceof JComponent) {
+                ((JComponent) component).updateUI();
+                setBorderToRollover(component);
             }
         }
     }
@@ -640,10 +638,10 @@
         // Put non-rollover borders on buttons. These borders reduce the margin.
         Component[] components = c.getComponents();
 
-        for ( int i = 0; i < components.length; ++i ) {
-            if ( components[ i ] instanceof JComponent ) {
-                ( (JComponent)components[ i ] ).updateUI();
-                setBorderToNonRollover( components[ i ] );
+        for (Component component : components) {
+            if (component instanceof JComponent) {
+                ((JComponent) component).updateUI();
+                setBorderToNonRollover(component);
             }
         }
     }
@@ -664,8 +662,8 @@
         // Put back the normal borders on buttons
         Component[] components = c.getComponents();
 
-        for ( int i = 0; i < components.length; ++i ) {
-            setBorderToNormal( components[ i ] );
+        for (Component component : components) {
+            setBorderToNormal(component);
         }
     }
 
@@ -681,7 +679,7 @@
         if (c instanceof AbstractButton) {
             AbstractButton b = (AbstractButton)c;
 
-            Border border = (Border)borderTable.get(b);
+            Border border = borderTable.get(b);
             if (border == null || border instanceof UIResource) {
                 borderTable.put(b, b.getBorder());
             }
@@ -721,7 +719,7 @@
         if (c instanceof AbstractButton) {
             AbstractButton b = (AbstractButton)c;
 
-            Border border = (Border)borderTable.get(b);
+            Border border = borderTable.get(b);
             if (border == null || border instanceof UIResource) {
                 borderTable.put(b, b.getBorder());
             }
@@ -765,10 +763,10 @@
         if (c instanceof AbstractButton) {
             AbstractButton b = (AbstractButton)c;
 
-            Border border = (Border)borderTable.remove(b);
+            Border border = borderTable.remove(b);
             b.setBorder(border);
 
-            Boolean value = (Boolean)rolloverTable.remove(b);
+            Boolean value = rolloverTable.remove(b);
             if (value != null) {
                 b.setRolloverEnabled(value.booleanValue());
             }
@@ -785,7 +783,7 @@
     }
 
     public void setFloating(boolean b, Point p) {
-        if (toolBar.isFloatable() == true) {
+        if (toolBar.isFloatable()) {
             boolean visible = false;
             Window ancestor = SwingUtilities.getWindowAncestor(toolBar);
             if (ancestor != null) {
@@ -953,7 +951,7 @@
 
     protected void dragTo(Point position, Point origin)
     {
-        if (toolBar.isFloatable() == true)
+        if (toolBar.isFloatable())
         {
           try
           {
@@ -1003,7 +1001,7 @@
 
     protected void floatAt(Point position, Point origin)
     {
-        if(toolBar.isFloatable() == true)
+        if(toolBar.isFloatable())
         {
           try
           {
@@ -1174,7 +1172,7 @@
             if (!tb.isEnabled()) {
                 return;
             }
-            if (isDragging == true) {
+            if (isDragging) {
                 Point position = evt.getPoint();
                 if (origin == null)
                     origin = evt.getComponent().getLocationOnScreen();
@@ -1242,7 +1240,7 @@
 
     protected class FrameListener extends WindowAdapter {
         public void windowClosing(WindowEvent w) {
-            if (toolBar.isFloatable() == true) {
+            if (toolBar.isFloatable()) {
                 if (dragWindow != null)
                     dragWindow.setVisible(false);
                 floating = false;
--- a/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -1263,7 +1263,7 @@
     }
 
     private Rectangle getDropLineRect(JTree.DropLocation loc) {
-        Rectangle rect = null;
+        Rectangle rect;
         TreePath path = loc.getPath();
         int index = loc.getChildIndex();
         boolean ltr = leftToRight;
@@ -2138,7 +2138,7 @@
                                  compositeRequestFocus(editingComponent);
                 boolean selectAll = true;
 
-                if(event != null && event instanceof MouseEvent) {
+                if(event != null) {
                     /* Find the component that will get forwarded all the
                        mouse events until mouseReleased. */
                     Point          componentPoint = SwingUtilities.convertPoint
@@ -3125,7 +3125,7 @@
 
     private static final TransferHandler defaultTransferHandler = new TreeTransferHandler();
 
-    static class TreeTransferHandler extends TransferHandler implements UIResource, Comparator {
+    static class TreeTransferHandler extends TransferHandler implements UIResource, Comparator<TreePath> {
 
         private JTree tree;
 
@@ -3156,9 +3156,7 @@
                 TreePath lastPath = null;
                 TreePath[] displayPaths = getDisplayOrderPaths(paths);
 
-                for (int i = 0; i < displayPaths.length; i++) {
-                    TreePath path = displayPaths[i];
-
+                for (TreePath path : displayPaths) {
                     Object node = path.getLastPathComponent();
                     boolean leaf = model.isLeaf(node);
                     String label = getDisplayString(path, true, leaf);
@@ -3179,9 +3177,9 @@
             return null;
         }
 
-        public int compare(Object o1, Object o2) {
-            int row1 = tree.getRowForPath((TreePath)o1);
-            int row2 = tree.getRowForPath((TreePath)o2);
+        public int compare(TreePath o1, TreePath o2) {
+            int row1 = tree.getRowForPath(o1);
+            int row2 = tree.getRowForPath(o2);
             return row1 - row2;
         }
 
@@ -3200,15 +3198,15 @@
          */
         TreePath[] getDisplayOrderPaths(TreePath[] paths) {
             // sort the paths to display order rather than selection order
-            ArrayList selOrder = new ArrayList();
-            for (int i = 0; i < paths.length; i++) {
-                selOrder.add(paths[i]);
+            ArrayList<TreePath> selOrder = new ArrayList<TreePath>();
+            for (TreePath path : paths) {
+                selOrder.add(path);
             }
             Collections.sort(selOrder, this);
             int n = selOrder.size();
             TreePath[] displayPaths = new TreePath[n];
             for (int i = 0; i < n; i++) {
-                displayPaths[i] = (TreePath) selOrder.get(i);
+                displayPaths[i] = selOrder.get(i);
             }
             return displayPaths;
         }
@@ -3321,10 +3319,7 @@
             InputMap inputMap = tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
             KeyStroke key = KeyStroke.getKeyStrokeForEvent(event);
 
-            if (inputMap != null && inputMap.get(key) != null) {
-                return true;
-            }
-            return false;
+            return inputMap != null && inputMap.get(key) != null;
         }
 
 
--- a/src/share/classes/javax/swing/plaf/basic/DragRecognitionSupport.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/DragRecognitionSupport.java	Fri Jul 25 17:50:36 2008 +0400
@@ -73,8 +73,7 @@
      * Returns whether or not the event is potentially part of a drag sequence.
      */
     public static boolean mousePressed(MouseEvent me) {
-        return ((DragRecognitionSupport)getDragRecognitionSupport()).
-            mousePressedImpl(me);
+        return getDragRecognitionSupport().mousePressedImpl(me);
     }
 
     /**
@@ -82,16 +81,14 @@
      * that started the recognition. Otherwise, return null.
      */
     public static MouseEvent mouseReleased(MouseEvent me) {
-        return ((DragRecognitionSupport)getDragRecognitionSupport()).
-            mouseReleasedImpl(me);
+        return getDragRecognitionSupport().mouseReleasedImpl(me);
     }
 
     /**
      * Returns whether or not a drag gesture recognition is ongoing.
      */
     public static boolean mouseDragged(MouseEvent me, BeforeDrag bd) {
-        return ((DragRecognitionSupport)getDragRecognitionSupport()).
-            mouseDraggedImpl(me, bd);
+        return getDragRecognitionSupport().mouseDraggedImpl(me, bd);
     }
 
     private void clearState() {
--- a/src/share/classes/javax/swing/plaf/basic/LazyActionMap.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/LazyActionMap.java	Fri Jul 25 17:50:36 2008 +0400
@@ -142,7 +142,7 @@
             Object loader = _loader;
 
             _loader = null;
-            Class klass = (Class)loader;
+            Class<?> klass = (Class<?>)loader;
             try {
                 Method method = klass.getDeclaredMethod("loadActionMap",
                                       new Class[] { LazyActionMap.class });
--- a/src/share/classes/javax/swing/plaf/metal/DefaultMetalTheme.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/metal/DefaultMetalTheme.java	Fri Jul 25 17:50:36 2008 +0400
@@ -387,9 +387,9 @@
          * that it is wrapped inside a <code>doPrivileged</code> call.
          */
         protected Font getPrivilegedFont(final int key) {
-            return (Font)java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction() {
-                    public Object run() {
+            return java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedAction<Font>() {
+                    public Font run() {
                         return Font.getFont(getDefaultPropertyName(key));
                     }
                 }
--- a/src/share/classes/javax/swing/plaf/metal/MetalBumps.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/metal/MetalBumps.java	Fri Jul 25 17:50:36 2008 +0400
@@ -49,7 +49,7 @@
     protected Color shadowColor;
     protected Color backColor;
 
-    protected static Vector buffers = new Vector();
+    protected static Vector<BumpBuffer> buffers = new Vector<BumpBuffer>();
     protected BumpBuffer buffer;
 
     public MetalBumps( Dimension bumpArea ) {
@@ -81,10 +81,7 @@
         }
         BumpBuffer result = null;
 
-        Enumeration elements = buffers.elements();
-
-        while ( elements.hasMoreElements() ) {
-            BumpBuffer aBuffer = (BumpBuffer)elements.nextElement();
+        for (BumpBuffer aBuffer : buffers) {
             if ( aBuffer.hasSameConfiguration(gc, aTopColor, aShadowColor,
                                               aBackColor)) {
                 result = aBuffer;
@@ -120,8 +117,7 @@
 
     public void paintIcon( Component c, Graphics g, int x, int y ) {
         GraphicsConfiguration gc = (g instanceof Graphics2D) ?
-                                     (GraphicsConfiguration)((Graphics2D)g).
-                                     getDeviceConfiguration() : null;
+                ((Graphics2D) g).getDeviceConfiguration() : null;
 
         buffer = getBuffer(gc, topColor, shadowColor, backColor);
 
--- a/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -782,7 +782,7 @@
                 } else if (s.equals("componentOrientation")) {
                     ComponentOrientation o = (ComponentOrientation)e.getNewValue();
                     JFileChooser cc = (JFileChooser)e.getSource();
-                    if (o != (ComponentOrientation)e.getOldValue()) {
+                    if (o != e.getOldValue()) {
                         cc.applyComponentOrientation(o);
                     }
                 } else if (s == "FileChooser.useShellFolder") {
@@ -927,7 +927,7 @@
      * Data model for a type-face selection combo-box.
      */
     protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
-        Vector directories = new Vector();
+        Vector<File> directories = new Vector<File>();
         int[] depths = null;
         File selectedDirectory = null;
         JFileChooser chooser = getFileChooser();
@@ -966,7 +966,7 @@
             // Get the canonical (full) path. This has the side
             // benefit of removing extraneous chars from the path,
             // for example /foo/bar/ becomes /foo/bar
-            File canonical = null;
+            File canonical;
             try {
                 canonical = ShellFolder.getNormalizedFile(directory);
             } catch (IOException e) {
@@ -979,7 +979,7 @@
                 File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
                                          : canonical;
                 File f = sf;
-                Vector path = new Vector(10);
+                Vector<File> path = new Vector<File>(10);
                 do {
                     path.addElement(f);
                 } while ((f = f.getParentFile()) != null);
@@ -987,7 +987,7 @@
                 int pathCount = path.size();
                 // Insert chain at appropriate place in vector
                 for (int i = 0; i < pathCount; i++) {
-                    f = (File)path.get(i);
+                    f = path.get(i);
                     if (directories.contains(f)) {
                         int topIndex = directories.indexOf(f);
                         for (int j = i-1; j >= 0; j--) {
@@ -1006,12 +1006,12 @@
         private void calculateDepths() {
             depths = new int[directories.size()];
             for (int i = 0; i < depths.length; i++) {
-                File dir = (File)directories.get(i);
+                File dir = directories.get(i);
                 File parent = dir.getParentFile();
                 depths[i] = 0;
                 if (parent != null) {
                     for (int j = i-1; j >= 0; j--) {
-                        if (parent.equals((File)directories.get(j))) {
+                        if (parent.equals(directories.get(j))) {
                             depths[i] = depths[j] + 1;
                             break;
                         }
@@ -1110,8 +1110,8 @@
             FileFilter currentFilter = getFileChooser().getFileFilter();
             boolean found = false;
             if(currentFilter != null) {
-                for(int i=0; i < filters.length; i++) {
-                    if(filters[i] == currentFilter) {
+                for (FileFilter filter : filters) {
+                    if (filter == currentFilter) {
                         found = true;
                     }
                 }
--- a/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java	Fri Jul 25 17:50:36 2008 +0400
@@ -598,7 +598,7 @@
             }
 
             // Some calculations that are needed more than once later on.
-            int oneHalf = (int)(iconSize / 2); // 16 -> 8
+            int oneHalf = iconSize / 2; // 16 -> 8
 
             g.translate(x, y);
 
@@ -1502,7 +1502,7 @@
 
         // PENDING: Replace this class with CachedPainter.
 
-        Vector images = new Vector(1, 1);
+        Vector<ImageGcPair> images = new Vector<ImageGcPair>(1, 1);
         ImageGcPair currentImageGcPair;
 
         class ImageGcPair {
@@ -1514,12 +1514,8 @@
             }
 
             boolean hasSameConfiguration(GraphicsConfiguration newGC) {
-                if (((newGC != null) && (newGC.equals(gc))) ||
-                    ((newGC == null) && (gc == null)))
-                {
-                    return true;
-                }
-                return false;
+                return ((newGC != null) && (newGC.equals(gc))) ||
+                        ((newGC == null) && (gc == null));
             }
 
         }
@@ -1528,9 +1524,7 @@
             if ((currentImageGcPair == null) ||
                 !(currentImageGcPair.hasSameConfiguration(newGC)))
             {
-                Enumeration elements = images.elements();
-                while (elements.hasMoreElements()) {
-                    ImageGcPair imgGcPair = (ImageGcPair)elements.nextElement();
+                for (ImageGcPair imgGcPair : images) {
                     if (imgGcPair.hasSameConfiguration(newGC)) {
                         currentImageGcPair = imgGcPair;
                         return imgGcPair.image;
--- a/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java	Fri Jul 25 17:50:36 2008 +0400
@@ -191,7 +191,7 @@
         extends BasicInternalFrameTitlePane.PropertyChangeHandler
     {
         public void propertyChange(PropertyChangeEvent evt) {
-            String prop = (String)evt.getPropertyName();
+            String prop = evt.getPropertyName();
             if( prop.equals(JInternalFrame.IS_SELECTED_PROPERTY) ) {
                 Boolean b = (Boolean)evt.getNewValue();
                 iconButton.putClientProperty("paintActive", b);
@@ -242,7 +242,7 @@
             }
 
             // Compute height.
-            int height = 0;
+            int height;
             if (isPalette) {
                 height = paletteTitleHeight;
             } else {
@@ -410,7 +410,7 @@
         g.drawLine ( width - 1, 0 , width -1, 0);
 
 
-        int titleLength = 0;
+        int titleLength;
         int xOffset = leftToRight ? 5 : width - 5;
         String frameTitle = frame.getTitle();
 
--- a/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Fri Jul 25 17:50:36 2008 +0400
@@ -2208,9 +2208,9 @@
                 if (methodName == null) {
                     return c.newInstance();
                 }
-                Method method = (Method)AccessController.doPrivileged(
-                    new PrivilegedAction() {
-                    public Object run() {
+                Method method = AccessController.doPrivileged(
+                    new PrivilegedAction<Method>() {
+                    public Method run() {
                         Method[] methods = c.getDeclaredMethods();
                         for (int counter = methods.length - 1; counter >= 0;
                              counter--) {
@@ -2273,7 +2273,7 @@
         }
     }
 
-    static ReferenceQueue queue = new ReferenceQueue();
+    static ReferenceQueue<LookAndFeel> queue = new ReferenceQueue<LookAndFeel>();
 
     static void flushUnreferenced() {
         AATextListener aatl;
@@ -2283,7 +2283,7 @@
     }
 
     static class AATextListener
-        extends WeakReference implements PropertyChangeListener {
+        extends WeakReference<LookAndFeel> implements PropertyChangeListener {
 
         private String key = SunToolkit.DESKTOPFONTHINTS;
 
@@ -2294,7 +2294,7 @@
         }
 
         public void propertyChange(PropertyChangeEvent pce) {
-            LookAndFeel laf = (LookAndFeel)get();
+            LookAndFeel laf = get();
             if (laf == null || laf != UIManager.getLookAndFeel()) {
                 dispose();
                 return;
@@ -2318,8 +2318,8 @@
         private static void updateWindowUI(Window window) {
             SwingUtilities.updateComponentTreeUI(window);
             Window ownedWins[] = window.getOwnedWindows();
-            for (int i=0; i < ownedWins.length; i++) {
-                updateWindowUI(ownedWins[i]);
+            for (Window w : ownedWins) {
+                updateWindowUI(w);
             }
         }
 
@@ -2328,8 +2328,8 @@
          */
         private static void updateAllUIs() {
             Frame appFrames[] = Frame.getFrames();
-            for (int j=0; j < appFrames.length; j++) {
-                updateWindowUI(appFrames[j]);
+            for (Frame frame : appFrames) {
+                updateWindowUI(frame);
             }
         }
 
--- a/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -164,15 +164,15 @@
                 }
             } else if(model.isSelected()) {
                 if(b.isRolloverEnabled() && model.isRollover()) {
-                        altIcon = (Icon) b.getRolloverSelectedIcon();
+                        altIcon = b.getRolloverSelectedIcon();
                         if (altIcon == null) {
-                                altIcon = (Icon) b.getSelectedIcon();
+                                altIcon = b.getSelectedIcon();
                         }
                 } else {
-                        altIcon = (Icon) b.getSelectedIcon();
+                        altIcon = b.getSelectedIcon();
                 }
             } else if(b.isRolloverEnabled() && model.isRollover()) {
-                altIcon = (Icon) b.getRolloverIcon();
+                altIcon = b.getRolloverIcon();
             }
 
             if(altIcon == null) {
--- a/src/share/classes/javax/swing/plaf/metal/MetalToolBarUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/metal/MetalToolBarUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -61,7 +61,7 @@
      * instances of JToolBars and JMenuBars and is used to find
      * JToolBars/JMenuBars that border each other.
      */
-    private static java.util.List components = new ArrayList();
+    private static List<WeakReference<JComponent>> components = new ArrayList<WeakReference<JComponent>>();
 
     /**
      * This protected field is implemenation specific. Do not access directly
@@ -95,7 +95,7 @@
             // typed to throw an NPE.
             throw new NullPointerException("JComponent must be non-null");
         }
-        components.add(new WeakReference(c));
+        components.add(new WeakReference<JComponent>(c));
     }
 
     /**
@@ -105,8 +105,7 @@
         for (int counter = components.size() - 1; counter >= 0; counter--) {
             // Search for the component, removing any flushed references
             // along the way.
-            WeakReference ref = (WeakReference)components.get(counter);
-            Object target = ((WeakReference)components.get(counter)).get();
+            JComponent target = components.get(counter).get();
 
             if (target == c || target == null) {
                 components.remove(counter);
--- a/src/share/classes/javax/swing/plaf/synth/DefaultSynthStyleFactory.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/DefaultSynthStyleFactory.java	Fri Jul 25 17:50:36 2008 +0400
@@ -63,7 +63,7 @@
     /**
      * Maps from a List (BakedArrayList to be precise) to the merged style.
      */
-    private Map _resolvedStyles;
+    private Map<BakedArrayList, SynthStyle> _resolvedStyles;
 
     /**
      * Used if there are no styles matching a widget.
@@ -74,7 +74,7 @@
     DefaultSynthStyleFactory() {
         _tmpList = new BakedArrayList(5);
         _styles = new ArrayList<StyleAssociation>();
-        _resolvedStyles = new HashMap();
+        _resolvedStyles = new HashMap<BakedArrayList, SynthStyle>();
     }
 
     public synchronized void addStyle(DefaultSynthStyle style,
@@ -138,7 +138,7 @@
      * Fetches any styles that match the passed into arguments into
      * <code>matches</code>.
      */
-    private void getMatchingStyles(java.util.List matches, JComponent c,
+    private void getMatchingStyles(List matches, JComponent c,
                                    Region id) {
         String idName = id.getLowerCaseName();
         String cName = c.getName();
@@ -166,7 +166,7 @@
     /**
      * Caches the specified style.
      */
-    private void cacheStyle(java.util.List styles, SynthStyle style) {
+    private void cacheStyle(List styles, SynthStyle style) {
         BakedArrayList cachedStyles = new BakedArrayList(styles);
 
         _resolvedStyles.put(cachedStyles, style);
@@ -175,11 +175,11 @@
     /**
      * Returns the cached style from the passed in arguments.
      */
-    private SynthStyle getCachedStyle(java.util.List styles) {
+    private SynthStyle getCachedStyle(List styles) {
         if (styles.size() == 0) {
             return null;
         }
-        return (SynthStyle)_resolvedStyles.get(styles);
+        return _resolvedStyles.get(styles);
     }
 
     /**
@@ -187,7 +187,7 @@
      * is reverse sorted, that is the most recently added style found to
      * match will be first.
      */
-    private SynthStyle mergeStyles(java.util.List styles) {
+    private SynthStyle mergeStyles(List styles) {
         int size = styles.size();
 
         if (size == 0) {
--- a/src/share/classes/javax/swing/plaf/synth/ImagePainter.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/ImagePainter.java	Fri Jul 25 17:50:36 2008 +0400
@@ -66,7 +66,7 @@
             Paint9Painter painter;
             if (cacheRef == null || (painter = cacheRef.get()) == null) {
                 painter = new Paint9Painter(30);
-                cacheRef = new WeakReference(painter);
+                cacheRef = new WeakReference<Paint9Painter>(painter);
                 AppContext.getAppContext().put(CACHE_KEY, cacheRef);
             }
             return painter;
--- a/src/share/classes/javax/swing/plaf/synth/Region.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/Region.java	Fri Jul 25 17:50:36 2008 +0400
@@ -67,8 +67,8 @@
  * @author Scott Violet
  */
 public class Region {
-    private static final Map uiToRegionMap = new HashMap();
-    private static final Map lowerCaseNameMap = new HashMap();
+    private static final Map<String, Region> uiToRegionMap = new HashMap<String, Region>();
+    private static final Map<Region, String> lowerCaseNameMap = new HashMap<Region, String>();
 
     /**
      * ArrowButton's are special types of buttons that also render a
@@ -451,15 +451,11 @@
 
 
     static Region getRegion(JComponent c) {
-        return (Region)uiToRegionMap.get(c.getUIClassID());
+        return uiToRegionMap.get(c.getUIClassID());
     }
 
     static void registerUIs(UIDefaults table) {
-        Iterator uis = uiToRegionMap.keySet().iterator();
-
-        while (uis.hasNext()) {
-            Object key = uis.next();
-
+        for (String key : uiToRegionMap.keySet()) {
             table.put(key, "javax.swing.plaf.synth.SynthLookAndFeel");
         }
     }
@@ -521,7 +517,7 @@
      */
     String getLowerCaseName() {
         synchronized(lowerCaseNameMap) {
-            String lowerCaseName = (String)lowerCaseNameMap.get(this);
+            String lowerCaseName = lowerCaseNameMap.get(this);
             if (lowerCaseName == null) {
                 lowerCaseName = getName().toLowerCase();
                 lowerCaseNameMap.put(this, lowerCaseName);
--- a/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -336,7 +336,7 @@
                     return oldValue;
                 } else {
                     // Must take the value from the editor and get the value and cast it to the new type.
-                    Class cls = oldValue.getClass();
+                    Class<?> cls = oldValue.getClass();
                     try {
                         Method method = cls.getMethod("valueOf", new Class[]{String.class});
                         newValue = method.invoke(oldValue, new Object[] { editor.getText()});
--- a/src/share/classes/javax/swing/plaf/synth/SynthContext.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthContext.java	Fri Jul 25 17:50:36 2008 +0400
@@ -39,7 +39,7 @@
  * @author Scott Violet
  */
 public class SynthContext {
-    private static final Map contextMap;
+    private static final Map<Class, List<SynthContext>> contextMap;
 
     private JComponent component;
     private Region region;
@@ -48,7 +48,7 @@
 
 
     static {
-        contextMap = new HashMap();
+        contextMap = new HashMap<Class, List<SynthContext>>();
     }
 
 
@@ -58,13 +58,13 @@
         SynthContext context = null;
 
         synchronized(contextMap) {
-            java.util.List instances = (java.util.List)contextMap.get(type);
+            List<SynthContext> instances = contextMap.get(type);
 
             if (instances != null) {
                 int size = instances.size();
 
                 if (size > 0) {
-                    context = (SynthContext)instances.remove(size - 1);
+                    context = instances.remove(size - 1);
                 }
             }
         }
@@ -81,11 +81,10 @@
 
     static void releaseContext(SynthContext context) {
         synchronized(contextMap) {
-            java.util.List instances = (java.util.List)contextMap.get(
-                                       context.getClass());
+            List<SynthContext> instances = contextMap.get(context.getClass());
 
             if (instances == null) {
-                instances = new ArrayList(5);
+                instances = new ArrayList<SynthContext>(5);
                 contextMap.put(context.getClass(), instances);
             }
             instances.add(context);
--- a/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -45,8 +45,8 @@
      * I would prefer to use UIResource instad of this.
      * Unfortunately Boolean is a final class
      */
-    private Boolean localTrue = new Boolean(true);
-    private Boolean localFalse = new Boolean(false);
+    private Boolean localTrue = Boolean.TRUE;
+    private Boolean localFalse = Boolean.FALSE;
 
     /**
      * Creates a UI for the JTextPane.
@@ -69,7 +69,7 @@
             c.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES,
                                 localTrue);
         }
-        updateStyle((JTextComponent)getComponent());
+        updateStyle(getComponent());
     }
 
     protected void uninstallDefaults() {
--- a/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java	Fri Jul 25 17:50:36 2008 +0400
@@ -416,7 +416,7 @@
      * the SynthIcon with a given SynthContext.
      */
     private static class SynthIconWrapper implements Icon {
-        private static final java.util.List CACHE = new java.util.ArrayList(1);
+        private static final java.util.List<SynthIconWrapper> CACHE = new java.util.ArrayList<SynthIconWrapper>(1);
 
         private SynthIcon synthIcon;
         private SynthContext context;
@@ -425,8 +425,7 @@
             synchronized(CACHE) {
                 int size = CACHE.size();
                 if (size > 0) {
-                    SynthIconWrapper wrapper = (SynthIconWrapper)CACHE.remove(
-                                               size - 1);
+                    SynthIconWrapper wrapper = CACHE.remove(size - 1);
                     wrapper.reset(icon, context);
                     return wrapper;
                 }
--- a/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java	Fri Jul 25 17:50:36 2008 +0400
@@ -197,18 +197,18 @@
 
     protected void addSystemMenuItems(JPopupMenu menu) {
         // PENDING: this should all be localizable!
-        JMenuItem mi = (JMenuItem)menu.add(restoreAction);
+        JMenuItem mi = menu.add(restoreAction);
         mi.setMnemonic('R');
-        mi = (JMenuItem)menu.add(moveAction);
+        mi = menu.add(moveAction);
         mi.setMnemonic('M');
-        mi = (JMenuItem)menu.add(sizeAction);
+        mi = menu.add(sizeAction);
         mi.setMnemonic('S');
-        mi = (JMenuItem)menu.add(iconifyAction);
+        mi = menu.add(iconifyAction);
         mi.setMnemonic('n');
-        mi = (JMenuItem)menu.add(maximizeAction);
+        mi = menu.add(maximizeAction);
         mi.setMnemonic('x');
         menu.add(new JSeparator());
-        mi = (JMenuItem)menu.add(closeAction);
+        mi = menu.add(closeAction);
         mi.setMnemonic('C');
     }
 
--- a/src/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java	Fri Jul 25 17:50:36 2008 +0400
@@ -107,7 +107,7 @@
      * Map of defaults table entries. This is populated via the load
      * method.
      */
-    private Map defaultsMap;
+    private Map<String, Object> defaultsMap;
 
     private Handler _handler;
 
@@ -308,8 +308,8 @@
             children = ((Container)c).getComponents();
         }
         if (children != null) {
-            for(int i = 0; i < children.length; i++) {
-                updateStyles(children[i]);
+            for (Component child : children) {
+                updateStyles(child);
             }
         }
     }
@@ -581,7 +581,7 @@
         }
 
         if (defaultsMap == null) {
-            defaultsMap = new HashMap();
+            defaultsMap = new HashMap<String, Object>();
         }
 
         new SynthParser().parse(input, (DefaultSynthStyleFactory) factory,
@@ -611,7 +611,7 @@
         }
 
         if (defaultsMap == null) {
-            defaultsMap = new HashMap();
+            defaultsMap = new HashMap<String, Object>();
         }
 
         InputStream input = url.openStream();
@@ -771,7 +771,7 @@
      */
     private static Object getAATextInfo() {
         String language = Locale.getDefault().getLanguage();
-        String desktop = (String)
+        String desktop =
             AccessController.doPrivileged(new GetPropertyAction("sun.desktop"));
 
         boolean isCjkLocale = (Locale.CHINESE.getLanguage().equals(language) ||
@@ -786,7 +786,7 @@
         return aaTextInfo;
     }
 
-    private static ReferenceQueue queue = new ReferenceQueue();
+    private static ReferenceQueue<LookAndFeel> queue = new ReferenceQueue<LookAndFeel>();
 
     private static void flushUnreferenced() {
         AATextListener aatl;
@@ -796,7 +796,7 @@
     }
 
     private static class AATextListener
-        extends WeakReference implements PropertyChangeListener {
+        extends WeakReference<LookAndFeel> implements PropertyChangeListener {
         private String key = SunToolkit.DESKTOPFONTHINTS;
 
         AATextListener(LookAndFeel laf) {
@@ -812,7 +812,7 @@
                 return;
             }
 
-            LookAndFeel laf = (LookAndFeel) get();
+            LookAndFeel laf = get();
             if (laf == null || laf != UIManager.getLookAndFeel()) {
                 dispose();
                 return;
@@ -835,8 +835,8 @@
         private static void updateWindowUI(Window window) {
             updateStyles(window);
             Window ownedWins[] = window.getOwnedWindows();
-            for (int i = 0; i < ownedWins.length; i++) {
-                updateWindowUI(ownedWins[i]);
+            for (Window w : ownedWins) {
+                updateWindowUI(w);
             }
         }
 
@@ -845,8 +845,8 @@
          */
         private static void updateAllUIs() {
             Frame appFrames[] = Frame.getFrames();
-            for (int i = 0; i < appFrames.length; i++) {
-                updateWindowUI(appFrames[i]);
+            for (Frame frame : appFrames) {
+                updateWindowUI(frame);
             }
         }
 
@@ -909,7 +909,7 @@
                 // register it on the new one.
                 KeyboardFocusManager manager =
                     (KeyboardFocusManager)evt.getSource();
-                if (((Boolean)newValue).equals(Boolean.FALSE)) {
+                if (newValue.equals(Boolean.FALSE)) {
                     manager.removePropertyChangeListener(_handler);
                 }
                 else {
--- a/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -106,7 +106,7 @@
            Icon checkIcon, Icon arrowIcon, int defaultTextIconGap,
            String acceleratorDelimiter) {
         JMenuItem b = (JMenuItem) c;
-        Icon icon = (Icon) b.getIcon();
+        Icon icon = b.getIcon();
         String text = b.getText();
         KeyStroke accelerator =  b.getAccelerator();
         String acceleratorText = "";
@@ -306,15 +306,15 @@
         if(b.getIcon() != null) {
             Icon icon;
             if(!model.isEnabled()) {
-                icon = (Icon) b.getDisabledIcon();
+                icon = b.getDisabledIcon();
             } else if(model.isPressed() && model.isArmed()) {
-                icon = (Icon) b.getPressedIcon();
+                icon = b.getPressedIcon();
                 if(icon == null) {
                     // Use default icon
-                    icon = (Icon) b.getIcon();
+                    icon = b.getIcon();
                 }
             } else {
-                icon = (Icon) b.getIcon();
+                icon = b.getIcon();
             }
 
             if (icon!=null) {
--- a/src/share/classes/javax/swing/plaf/synth/SynthParser.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthParser.java	Fri Jul 25 17:50:36 2008 +0400
@@ -40,6 +40,7 @@
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.StringTokenizer;
@@ -136,7 +137,7 @@
      * Array of state infos for the current style. These are pushed to the
      * style when </style> is received.
      */
-    private java.util.List _stateInfos;
+    private List<ParsedSynthStyle.StateInfo> _stateInfos;
 
     /**
      * Current style.
@@ -151,7 +152,7 @@
     /**
      * Bindings for the current InputMap
      */
-    private java.util.List _inputMapBindings;
+    private List<String> _inputMapBindings;
 
     /**
      * ID for the input map. This is cached as
@@ -177,30 +178,30 @@
     /**
      * List of ColorTypes. This is populated in startColorType.
      */
-    private java.util.List _colorTypes;
+    private List<ColorType> _colorTypes;
 
     /**
      * defaultsPropertys are placed here.
      */
-    private Map _defaultsMap;
+    private Map<String, Object> _defaultsMap;
 
     /**
      * List of SynthStyle.Painters that will be applied to the current style.
      */
-    private java.util.List _stylePainters;
+    private List<ParsedSynthStyle.PainterInfo> _stylePainters;
 
     /**
      * List of SynthStyle.Painters that will be applied to the current state.
      */
-    private java.util.List _statePainters;
+    private List<ParsedSynthStyle.PainterInfo> _statePainters;
 
     SynthParser() {
         _mapping = new HashMap<String,Object>();
-        _stateInfos = new ArrayList();
-        _colorTypes = new ArrayList();
-        _inputMapBindings = new ArrayList();
-        _stylePainters = new ArrayList();
-        _statePainters = new ArrayList();
+        _stateInfos = new ArrayList<ParsedSynthStyle.StateInfo>();
+        _colorTypes = new ArrayList<ColorType>();
+        _inputMapBindings = new ArrayList<String>();
+        _stylePainters = new ArrayList<ParsedSynthStyle.PainterInfo>();
+        _statePainters = new ArrayList<ParsedSynthStyle.PainterInfo>();
     }
 
     /**
@@ -219,7 +220,7 @@
     public void parse(InputStream inputStream,
                       DefaultSynthStyleFactory factory,
                       URL urlResourceBase, Class<?> classResourceBase,
-                      Map defaultsMap)
+                      Map<String, Object> defaultsMap)
                       throws ParseException, IllegalArgumentException {
         if (inputStream == null || factory == null ||
             (urlResourceBase == null && classResourceBase == null)) {
@@ -333,7 +334,7 @@
      * type type, this will throw an exception.
      */
     private Object lookup(String key, Class type) throws SAXException {
-        Object value = null;
+        Object value;
         if (_handler != null) {
             if ((value = _handler.lookup(key)) != null) {
                 return checkCast(value, type);
@@ -423,15 +424,12 @@
     private void endStyle() throws SAXException {
         int size = _stylePainters.size();
         if (size > 0) {
-            _style.setPainters((ParsedSynthStyle.PainterInfo[])
-                  _stylePainters.toArray(new ParsedSynthStyle.
-                  PainterInfo[size]));
+            _style.setPainters(_stylePainters.toArray(new ParsedSynthStyle.PainterInfo[size]));
             _stylePainters.clear();
         }
         size = _stateInfos.size();
         if (size > 0) {
-            _style.setStateInfo((ParsedSynthStyle.StateInfo[])_stateInfos.
-                 toArray(new ParsedSynthStyle.StateInfo[size]));
+            _style.setStateInfo(_stateInfos.toArray(new ParsedSynthStyle.StateInfo[size]));
             _stateInfos.clear();
         }
         _style = null;
@@ -501,9 +499,7 @@
     private void endState() throws SAXException {
         int size = _statePainters.size();
         if (size > 0) {
-            _stateInfo.setPainters((ParsedSynthStyle.PainterInfo[])
-                  _statePainters.toArray(new ParsedSynthStyle.
-                  PainterInfo[size]));
+            _stateInfo.setPainters(_statePainters.toArray(new ParsedSynthStyle.PainterInfo[size]));
             _statePainters.clear();
         }
         _stateInfo = null;
@@ -684,8 +680,7 @@
             int max = 0;
             for (int counter = _colorTypes.size() - 1; counter >= 0;
                      counter--) {
-                max = Math.max(max, ((ColorType)_colorTypes.get(counter)).
-                               getID());
+                max = Math.max(max, _colorTypes.get(counter).getID());
             }
             if (colors == null || colors.length <= max) {
                 Color[] newColors = new Color[max + 1];
@@ -696,7 +691,7 @@
             }
             for (int counter = _colorTypes.size() - 1; counter >= 0;
                      counter--) {
-                colors[((ColorType)_colorTypes.get(counter)).getID()] = color;
+                colors[_colorTypes.get(counter).getID()] = color;
             }
             _stateInfo.setColors(colors);
         }
@@ -705,7 +700,7 @@
     private void startProperty(AttributeList attributes,
                                Object property) throws SAXException {
         Object value = null;
-        Object key = null;
+        String key = null;
         // Type of the value: 0=idref, 1=boolean, 2=dimension, 3=insets,
         // 4=integer,5=string
         int iType = 0;
@@ -1027,7 +1022,7 @@
         }
     }
 
-    private void addPainterOrMerge(java.util.List painters, String method,
+    private void addPainterOrMerge(List<ParsedSynthStyle.PainterInfo> painters, String method,
                                    SynthPainter painter, int direction) {
         ParsedSynthStyle.PainterInfo painterInfo;
         painterInfo = new ParsedSynthStyle.PainterInfo(method,
--- a/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -48,13 +48,13 @@
      * Keys to use for forward focus traversal when the JComponent is
      * managing focus.
      */
-    private static Set managingFocusForwardTraversalKeys;
+    private static Set<KeyStroke> managingFocusForwardTraversalKeys;
 
     /**
      * Keys to use for backward focus traversal when the JComponent is
      * managing focus.
      */
-    private static Set managingFocusBackwardTraversalKeys;
+    private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
 
     /**
      * Style for the JSplitPane.
@@ -96,7 +96,7 @@
 
         // focus forward traversal key
         if (managingFocusForwardTraversalKeys==null) {
-            managingFocusForwardTraversalKeys = new HashSet();
+            managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
             managingFocusForwardTraversalKeys.add(
                 KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
         }
@@ -104,7 +104,7 @@
                                         managingFocusForwardTraversalKeys);
         // focus backward traversal key
         if (managingFocusBackwardTraversalKeys==null) {
-            managingFocusBackwardTraversalKeys = new HashSet();
+            managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
             managingFocusBackwardTraversalKeys.add(
                 KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
         }
--- a/src/share/classes/javax/swing/plaf/synth/SynthStyle.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthStyle.java	Fri Jul 25 17:50:36 2008 +0400
@@ -53,7 +53,7 @@
     /**
      * Contains the default values for certain properties.
      */
-    private static Map DEFAULT_VALUES;
+    private static Map<Object, Object> DEFAULT_VALUES;
 
     /**
      * Shared SynthGraphics.
@@ -715,7 +715,7 @@
     private static Object getDefaultValue(Object key) {
         synchronized(SynthStyle.class) {
             if (DEFAULT_VALUES == null) {
-                DEFAULT_VALUES = new HashMap();
+                DEFAULT_VALUES = new HashMap<Object, Object>();
                 populateDefaultValues();
             }
             Object value = DEFAULT_VALUES.get(key);
--- a/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -66,7 +66,7 @@
     protected void installDefaults() {
         // Installs the text cursor on the component
         super.installDefaults();
-        updateStyle((JTextComponent)getComponent());
+        updateStyle(getComponent());
     }
 
     protected void uninstallDefaults() {
--- a/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -232,7 +232,7 @@
     protected void installDefaults() {
         // Installs the text cursor on the component
         super.installDefaults();
-        updateStyle((JTextComponent)getComponent());
+        updateStyle(getComponent());
         getComponent().addFocusListener(this);
     }
 
--- a/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Fri Jul 25 17:50:36 2008 +0400
@@ -390,7 +390,7 @@
     }
 
     private Rectangle getDropLineRect(JTree.DropLocation loc) {
-        Rectangle rect = null;
+        Rectangle rect;
         TreePath path = loc.getPath();
         int index = loc.getChildIndex();
         boolean ltr = tree.getComponentOrientation().isLeftToRight();
@@ -523,7 +523,7 @@
         // Don't paint the renderer if editing this row.
         boolean selected = tree.isRowSelected(row);
 
-        JTree.DropLocation dropLocation = (JTree.DropLocation)tree.getDropLocation();
+        JTree.DropLocation dropLocation = tree.getDropLocation();
         boolean isDrop = dropLocation != null
                          && dropLocation.getChildIndex() == -1
                          && path == dropLocation.getPath();
--- a/src/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java	Fri Jul 25 17:50:36 2008 +0400
@@ -44,7 +44,7 @@
  * @author Scott Violet
  */
 public class DefaultSynthStyle extends SynthStyle implements Cloneable {
-    private static final Object PENDING = new String("Pending");
+    private static final String PENDING = "Pending";
 
     /**
      * Should the component be opaque?
@@ -690,8 +690,8 @@
         StateInfo[] states = getStateInfo();
         if (states != null) {
             buf.append("states[");
-            for (int i = 0; i < states.length; i++) {
-                buf.append(states[i].toString()).append(',');
+            for (StateInfo state : states) {
+                buf.append(state.toString()).append(',');
             }
             buf.append(']').append(',');
         }
@@ -888,7 +888,7 @@
          * Returns the number of states that are similar between the
          * ComponentState this StateInfo represents and val.
          */
-        private final int getMatchCount(int val) {
+        private int getMatchCount(int val) {
             // This comes from BigInteger.bitCnt
             val &= state;
             val -= (0xaaaaaaaa & val) >>> 1;
--- a/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Fri Jul 25 14:14:30 2008 +0400
+++ b/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Fri Jul 25 17:50:36 2008 +0400
@@ -735,7 +735,7 @@
      * Data model for a type-face selection combo-box.
      */
     protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
-        Vector directories = new Vector();
+        Vector<File> directories = new Vector<File>();
         int[] depths = null;
         File selectedDirectory = null;
         JFileChooser chooser = getFileChooser();
@@ -778,7 +778,7 @@
             // Get the canonical (full) path. This has the side
             // benefit of removing extraneous chars from the path,
             // for example /foo/bar/ becomes /foo/bar
-            File canonical = null;
+            File canonical;
             try {
                 canonical = directory.getCanonicalFile();
             } catch (IOException e) {
@@ -791,7 +791,7 @@
                 File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
                                          : canonical;
                 File f = sf;
-                Vector path = new Vector(10);
+                Vector<File> path = new Vector<File>(10);
                 do {
                     path.addElement(f);
                 } while ((f = f.getParentFile()) != null);
@@ -799,7 +799,7 @@
                 int pathCount = path.size();
                 // Insert chain at appropriate place in vector
                 for (int i = 0; i < pathCount; i++) {
-                    f = (File)path.get(i);
+                    f = path.get(i);
                     if (directories.contains(f)) {
                         int topIndex = directories.indexOf(f);
                         for (int j = i-1; j >= 0; j--) {
@@ -818,12 +818,12 @@
         private void calculateDepths() {
             depths = new int[directories.size()];
             for (int i = 0; i < depths.length; i++) {
-                File dir = (File)directories.get(i);
+                File dir = directories.get(i);
                 File parent = dir.getParentFile();
                 depths[i] = 0;
                 if (parent != null) {
                     for (int j = i-1; j >= 0; j--) {
-                        if (parent.equals((File)directories.get(j))) {
+                        if (parent.equals(directories.get(j))) {
                             depths[i] = depths[j] + 1;
                             break;
                         }
@@ -940,8 +940,8 @@
             FileFilter currentFilter = getFileChooser().getFileFilter();
             boolean found = false;
             if(currentFilter != null) {
-                for(int i=0; i < filters.length; i++) {
-                    if(filters[i] == currentFilter) {
+                for (FileFilter filter : filters) {
+                    if (filter == currentFilter) {
                         found = true;
                     }
                 }