Merge
authortbell
Wed, 25 Jun 2008 16:44:55 -0700
changeset 714 6a05e0bdaee5
parent 713 e5675c136659 (current diff)
parent 683 a267ab9d1dda (diff)
child 715 f16baef3a20e
child 786 3cfaed48dbf4
Merge
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java	Wed Jun 25 16:44:55 2008 -0700
@@ -1222,9 +1222,7 @@
             "FileChooser.enterFileNameLabelMnemonic", new Integer (KeyEvent.VK_N), // 'n'
             "FileChooser.ancestorInputMap",
                new UIDefaults.LazyInputMap(new Object[] {
-                     "ESCAPE", "cancelSelection",
-                     "ENTER", "approveSelection",
-                "ctrl ENTER", "approveSelection"
+                     "ESCAPE", "cancelSelection"
                  }),
 
 
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Wed Jun 25 16:44:55 2008 -0700
@@ -825,9 +825,7 @@
                      "ESCAPE", "cancelSelection",
                      "F2", "editFileName",
                      "F5", "refresh",
-                     "BACK_SPACE", "Go Up",
-                     "ENTER", "approveSelection",
-                "ctrl ENTER", "approveSelection"
+                     "BACK_SPACE", "Go Up"
                  }),
 
             "FileView.directoryIcon", SwingUtilities2.makeIcon(getClass(),
--- a/jdk/src/share/classes/java/beans/EventHandler.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/java/beans/EventHandler.java	Wed Jun 25 16:44:55 2008 -0700
@@ -636,7 +636,7 @@
      * time a mouse button is pressed, one would write:
      *<blockquote>
      *<pre>
-     *EventHandler.create(MouseListener.class, "mousePressed", target, "origin", "point");
+     *EventHandler.create(MouseListener.class, target, "origin", "point", "mousePressed");
      *</pre>
      *</blockquote>
      *
--- a/jdk/src/share/classes/java/io/File.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/java/io/File.java	Wed Jun 25 16:44:55 2008 -0700
@@ -25,6 +25,7 @@
 
 package java.io;
 
+import java.beans.ConstructorProperties;
 import java.net.URI;
 import java.net.URL;
 import java.net.MalformedURLException;
@@ -234,6 +235,7 @@
      * @throws  NullPointerException
      *          If the <code>pathname</code> argument is <code>null</code>
      */
+    @ConstructorProperties("path")
     public File(String pathname) {
         if (pathname == null) {
             throw new NullPointerException();
--- a/jdk/src/share/classes/javax/swing/JFileChooser.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/JFileChooser.java	Wed Jun 25 16:44:55 2008 -0700
@@ -770,7 +770,8 @@
      * @since 1.4
      */
     protected JDialog createDialog(Component parent) throws HeadlessException {
-        String title = getUI().getDialogTitle(this);
+        FileChooserUI ui = getUI();
+        String title = ui.getDialogTitle(this);
         putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY,
                           title);
 
@@ -794,6 +795,7 @@
                 dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
             }
         }
+        dialog.getRootPane().setDefaultButton(ui.getDefaultButton(this));
         dialog.pack();
         dialog.setLocationRelativeTo(parent);
 
--- a/jdk/src/share/classes/javax/swing/JPopupMenu.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/JPopupMenu.java	Wed Jun 25 16:44:55 2008 -0700
@@ -41,6 +41,7 @@
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicComboPopup;
 import javax.swing.event.*;
+import sun.security.util.SecurityConstants;
 
 import java.applet.Applet;
 
@@ -320,17 +321,67 @@
      * This adustment may be cancelled by invoking the application with
      * -Djavax.swing.adjustPopupLocationToFit=false
      */
-    Point adjustPopupLocationToFitScreen(int xposition, int yposition) {
-        Point p = new Point(xposition, yposition);
+    Point adjustPopupLocationToFitScreen(int xPosition, int yPosition) {
+        Point popupLocation = new Point(xPosition, yPosition);
+
+        if(popupPostionFixDisabled == true || GraphicsEnvironment.isHeadless()) {
+            return popupLocation;
+        }
 
-        if(popupPostionFixDisabled == true || GraphicsEnvironment.isHeadless())
-            return p;
+        // Get screen bounds
+        Rectangle scrBounds;
+        GraphicsConfiguration gc = getCurrentGraphicsConfiguration(popupLocation);
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        if(gc != null) {
+            // If we have GraphicsConfiguration use it to get screen bounds
+            scrBounds = gc.getBounds();
+        } else {
+            // If we don't have GraphicsConfiguration use primary screen
+            scrBounds = new Rectangle(toolkit.getScreenSize());
+        }
 
-        Toolkit toolkit = Toolkit.getDefaultToolkit();
-        Rectangle screenBounds;
+        // Calculate the screen size that popup should fit
+        Dimension popupSize = JPopupMenu.this.getPreferredSize();
+        int popupRightX = popupLocation.x + popupSize.width;
+        int popupBottomY = popupLocation.y + popupSize.height;
+        int scrWidth = scrBounds.width;
+        int scrHeight = scrBounds.height;
+        if (!canPopupOverlapTaskBar()) {
+            // Insets include the task bar. Take them into account.
+            Insets scrInsets = toolkit.getScreenInsets(gc);
+            scrBounds.x += scrInsets.left;
+            scrBounds.y += scrInsets.top;
+            scrWidth -= scrInsets.left + scrInsets.right;
+            scrHeight -= scrInsets.top + scrInsets.bottom;
+        }
+        int scrRightX = scrBounds.x + scrWidth;
+        int scrBottomY = scrBounds.y + scrHeight;
+
+        // Ensure that popup menu fits the screen
+        if (popupRightX > scrRightX) {
+            popupLocation.x = scrRightX - popupSize.width;
+            if( popupLocation.x < scrBounds.x ) {
+                popupLocation.x = scrBounds.x ;
+            }
+        }
+        if (popupBottomY > scrBottomY) {
+            popupLocation.y = scrBottomY - popupSize.height;
+            if( popupLocation.y < scrBounds.y ) {
+                popupLocation.y = scrBounds.y;
+            }
+        }
+
+        return popupLocation;
+    }
+
+    /**
+     * Tries to find GraphicsConfiguration
+     * that contains the mouse cursor position.
+     * Can return null.
+     */
+    private GraphicsConfiguration getCurrentGraphicsConfiguration(
+            Point popupLocation) {
         GraphicsConfiguration gc = null;
-        // Try to find GraphicsConfiguration, that includes mouse
-        // pointer position
         GraphicsEnvironment ge =
             GraphicsEnvironment.getLocalGraphicsEnvironment();
         GraphicsDevice[] gd = ge.getScreenDevices();
@@ -338,50 +389,36 @@
             if(gd[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                 GraphicsConfiguration dgc =
                     gd[i].getDefaultConfiguration();
-                if(dgc.getBounds().contains(p)) {
+                if(dgc.getBounds().contains(popupLocation)) {
                     gc = dgc;
                     break;
                 }
             }
         }
-
         // If not found and we have invoker, ask invoker about his gc
         if(gc == null && getInvoker() != null) {
             gc = getInvoker().getGraphicsConfiguration();
         }
-
-        if(gc != null) {
-            // If we have GraphicsConfiguration use it to get
-            // screen bounds
-            screenBounds = gc.getBounds();
-        } else {
-            // If we don't have GraphicsConfiguration use primary screen
-            screenBounds = new Rectangle(toolkit.getScreenSize());
-        }
-
-        Dimension size;
-
-        size = JPopupMenu.this.getPreferredSize();
+        return gc;
+    }
 
-        // Use long variables to prevent overflow
-        long pw = (long) p.x + (long) size.width;
-        long ph = (long) p.y + (long) size.height;
-
-        if( pw > screenBounds.x + screenBounds.width )
-             p.x = screenBounds.x + screenBounds.width - size.width;
-
-        if( ph > screenBounds.y + screenBounds.height)
-             p.y = screenBounds.y + screenBounds.height - size.height;
-
-        /* Change is made to the desired (X,Y) values, when the
-           PopupMenu is too tall OR too wide for the screen
-        */
-        if( p.x < screenBounds.x )
-            p.x = screenBounds.x ;
-        if( p.y < screenBounds.y )
-            p.y = screenBounds.y;
-
-        return p;
+    /**
+     * Checks that there are enough security permissions
+     * to make popup "always on top", which allows to show it above the task bar.
+     */
+    static boolean canPopupOverlapTaskBar() {
+        boolean result = true;
+        try {
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                sm.checkPermission(
+                        SecurityConstants.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
+            }
+        } catch (SecurityException se) {
+            // There is no permission to show popups over the task bar
+            result = false;
+        }
+        return result;
     }
 
 
--- a/jdk/src/share/classes/javax/swing/JSlider.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/JSlider.java	Wed Jun 25 16:44:55 2008 -0700
@@ -25,18 +25,15 @@
 
 package javax.swing;
 
-import javax.swing.border.*;
 import javax.swing.event.*;
 import javax.swing.plaf.*;
 import javax.accessibility.*;
 
 import java.io.Serializable;
 import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
 import java.io.IOException;
 
-import java.awt.Color;
-import java.awt.Font;
+import java.awt.*;
 import java.util.*;
 import java.beans.*;
 
@@ -409,8 +406,7 @@
      * @since 1.4
      */
     public ChangeListener[] getChangeListeners() {
-        return (ChangeListener[])listenerList.getListeners(
-                ChangeListener.class);
+        return listenerList.getListeners(ChangeListener.class);
     }
 
 
@@ -642,9 +638,7 @@
     /**
      * Sets the model's {@code valueIsAdjusting} property.  Slider look and
      * feel implementations should set this property to {@code true} when
-     * a knob drag begins, and to {@code false} when the drag ends.  The
-     * slider model will not generate {@code ChangeEvent}s while
-     * {@code valueIsAdjusting} is {@code true}.
+     * a knob drag begins, and to {@code false} when the drag ends.
      *
      * @param b the new value for the {@code valueIsAdjusting} property
      * @see   #getValueIsAdjusting
@@ -764,6 +758,33 @@
         updateLabelSizes();
     }
 
+    /**
+     * {@inheritDoc}
+     * @since 1.7
+     */
+    public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
+        if (!isShowing()) {
+            return false;
+        }
+
+        // Check that there is a label with such image
+        Enumeration elements = labelTable.elements();
+
+        while (elements.hasMoreElements()) {
+            Component component = (Component) elements.nextElement();
+
+            if (component instanceof JLabel) {
+                JLabel label = (JLabel) component;
+
+                if (SwingUtilities.doesIconReferenceImage(label.getIcon(), img) ||
+                        SwingUtilities.doesIconReferenceImage(label.getDisabledIcon(), img)) {
+                    return super.imageUpdate(img, infoflags, x, y, w, h);
+                }
+            }
+        }
+
+        return false;
+    }
 
     /**
      * Returns the dictionary of what labels to draw at which values.
@@ -826,17 +847,16 @@
      * @see JComponent#updateUI
      */
     protected void updateLabelUIs() {
-        if ( getLabelTable() == null ) {
+        Dictionary labelTable = getLabelTable();
+
+        if (labelTable == null) {
             return;
         }
-        Enumeration labels = getLabelTable().keys();
+        Enumeration labels = labelTable.keys();
         while ( labels.hasMoreElements() ) {
-            Object value = getLabelTable().get( labels.nextElement() );
-            if ( value instanceof JComponent ) {
-                JComponent component = (JComponent)value;
-                component.updateUI();
-                component.setSize( component.getPreferredSize()  );
-            }
+            JComponent component = (JComponent) labelTable.get(labels.nextElement());
+            component.updateUI();
+            component.setSize(component.getPreferredSize());
         }
     }
 
@@ -845,11 +865,8 @@
         if (labelTable != null) {
             Enumeration labels = labelTable.elements();
             while (labels.hasMoreElements()) {
-                Object value = labels.nextElement();
-                if (value instanceof JComponent) {
-                    JComponent component = (JComponent)value;
-                    component.setSize(component.getPreferredSize());
-                }
+                JComponent component = (JComponent) labels.nextElement();
+                component.setSize(component.getPreferredSize());
             }
         }
     }
@@ -960,14 +977,14 @@
                 if ( e.getPropertyName().equals( "minimum" ) ||
                      e.getPropertyName().equals( "maximum" ) ) {
 
-                    Enumeration keys = getLabelTable().keys();
-                    Object key = null;
+                    Dictionary labelTable = getLabelTable();
+                    Enumeration keys = labelTable.keys();
                     Hashtable hashtable = new Hashtable();
 
                     // Save the labels that were added by the developer
                     while ( keys.hasMoreElements() ) {
-                        key = keys.nextElement();
-                        Object value = getLabelTable().get( key );
+                        Object key = keys.nextElement();
+                        Object value = labelTable.get(key);
                         if ( !(value instanceof LabelUIResource) ) {
                             hashtable.put( key, value );
                         }
@@ -979,7 +996,7 @@
                     // Add the saved labels
                     keys = hashtable.keys();
                     while ( keys.hasMoreElements() ) {
-                        key = keys.nextElement();
+                        Object key = keys.nextElement();
                         put( key, hashtable.get( key ) );
                     }
 
@@ -996,8 +1013,10 @@
 
         SmartHashtable table = new SmartHashtable( increment, start );
 
-        if ( getLabelTable() != null && (getLabelTable() instanceof PropertyChangeListener) ) {
-            removePropertyChangeListener( (PropertyChangeListener)getLabelTable() );
+        Dictionary labelTable = getLabelTable();
+
+        if (labelTable != null && (labelTable instanceof PropertyChangeListener)) {
+            removePropertyChangeListener((PropertyChangeListener) labelTable);
         }
 
         addPropertyChangeListener( table );
--- a/jdk/src/share/classes/javax/swing/PopupFactory.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/PopupFactory.java	Wed Jun 25 16:44:55 2008 -0700
@@ -548,47 +548,46 @@
         }
 
         /**
-         * Returns true if the Popup can fit on the screen.
+         * Returns true if popup can fit the screen and the owner's top parent.
+         * It determines can popup be lightweight or mediumweight.
          */
         boolean fitsOnScreen() {
+            boolean result = false;
             Component component = getComponent();
-
             if (owner != null && component != null) {
-                Container parent;
-                int width = component.getWidth();
-                int height = component.getHeight();
-                for(parent = owner.getParent(); parent != null ;
-                    parent = parent.getParent()) {
-                    if (parent instanceof JFrame ||
-                        parent instanceof JDialog ||
-                        parent instanceof JWindow) {
+                Container parent = (Container) SwingUtilities.getRoot(owner);
+                int popupWidth = component.getWidth();
+                int popupHeight = component.getHeight();
+                Rectangle parentBounds = parent.getBounds();
+                if (parent instanceof JFrame ||
+                    parent instanceof JDialog ||
+                    parent instanceof JWindow) {
+
+                    Insets i = parent.getInsets();
+                    parentBounds.x += i.left;
+                    parentBounds.y += i.top;
+                    parentBounds.width -= i.left + i.right;
+                    parentBounds.height -= i.top + i.bottom;
 
-                        Rectangle r = parent.getBounds();
-                        Insets i = parent.getInsets();
-                        r.x += i.left;
-                        r.y += i.top;
-                        r.width -= (i.left + i.right);
-                        r.height -= (i.top + i.bottom);
-
-                        GraphicsConfiguration gc = parent.getGraphicsConfiguration();
+                    if (JPopupMenu.canPopupOverlapTaskBar()) {
+                        GraphicsConfiguration gc =
+                                parent.getGraphicsConfiguration();
                         Rectangle popupArea = getContainerPopupArea(gc);
-                        return r.intersection(popupArea).contains(x, y, width, height);
-
-                    } else if (parent instanceof JApplet) {
-                        Rectangle r = parent.getBounds();
-                        Point p  = parent.getLocationOnScreen();
-
-                        r.x = p.x;
-                        r.y = p.y;
-                        return r.contains(x, y, width, height);
-                    } else if (parent instanceof Window ||
-                               parent instanceof Applet) {
-                        // No suitable swing component found
-                        break;
+                        result = parentBounds.intersection(popupArea)
+                                .contains(x, y, popupWidth, popupHeight);
+                    } else {
+                        result = parentBounds
+                                .contains(x, y, popupWidth, popupHeight);
                     }
+                } else if (parent instanceof JApplet) {
+                    Point p = parent.getLocationOnScreen();
+                    parentBounds.x = p.x;
+                    parentBounds.y = p.y;
+                    result = parentBounds
+                            .contains(x, y, popupWidth, popupHeight);
                 }
             }
-            return false;
+            return result;
         }
 
         Rectangle getContainerPopupArea(GraphicsConfiguration gc) {
--- a/jdk/src/share/classes/javax/swing/plaf/FileChooserUI.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/FileChooserUI.java	Wed Jun 25 16:44:55 2008 -0700
@@ -25,7 +25,7 @@
 
 package javax.swing.plaf;
 
-import javax.swing.JFileChooser;
+import javax.swing.*;
 import javax.swing.filechooser.FileFilter;
 import javax.swing.filechooser.FileView;
 import java.io.File;
@@ -46,4 +46,15 @@
 
     public abstract void rescanCurrentDirectory(JFileChooser fc);
     public abstract void ensureFileIsVisible(JFileChooser fc, File f);
+
+    /**
+     * Returns default button for current <code>LookAndFeel</code>.
+     * <code>JFileChooser</code> will use this button as default button
+     * for dialog windows.
+     *
+     * @since 1.7
+     */
+    public JButton getDefaultButton(JFileChooser fc) {
+        return null;
+    }
 }
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java	Wed Jun 25 16:44:55 2008 -0700
@@ -196,7 +196,7 @@
     }
 
     protected void sort(Vector<? extends File> v){
-        ShellFolder.sortFiles(v);
+        ShellFolder.sort(v);
     }
 
     // Obsolete - not used
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java	Wed Jun 25 16:44:55 2008 -0700
@@ -384,6 +384,10 @@
         return null;
     }
 
+    public JButton getDefaultButton(JFileChooser fc) {
+        return getApproveButton(fc);
+    }
+
     public String getApproveButtonToolTipText(JFileChooser fc) {
         String tooltipText = fc.getApproveButtonToolTipText();
         if(tooltipText != null) {
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java	Wed Jun 25 16:44:55 2008 -0700
@@ -25,25 +25,12 @@
 
 package javax.swing.plaf.basic;
 
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Adjustable;
 import java.awt.event.*;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Dimension;
-import java.awt.Rectangle;
-import java.awt.Point;
-import java.awt.Insets;
-import java.awt.Color;
-import java.awt.IllegalComponentStateException;
-import java.awt.Polygon;
+import java.awt.*;
 import java.beans.*;
 import java.util.Dictionary;
 import java.util.Enumeration;
 
-import javax.swing.border.AbstractBorder;
-
 import javax.swing.*;
 import javax.swing.event.*;
 import javax.swing.plaf.*;
@@ -409,7 +396,7 @@
                 Enumeration elements = dictionary.elements();
                 int baseline = -1;
                 while (elements.hasMoreElements()) {
-                    Component label = (Component)elements.nextElement();
+                    JComponent label = (JComponent) elements.nextElement();
                     Dimension pref = label.getPreferredSize();
                     int labelBaseline = label.getBaseline(pref.width,
                                                           pref.height);
@@ -634,7 +621,7 @@
 
 
     protected void calculateTrackRect() {
-        int centerSpacing = 0; // used to center sliders added using BorderLayout.CENTER (bug 4275631)
+        int centerSpacing; // used to center sliders added using BorderLayout.CENTER (bug 4275631)
         if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
             centerSpacing = thumbRect.height;
             if ( slider.getPaintTicks() ) centerSpacing += getTickLength();
@@ -764,7 +751,7 @@
         if ( dictionary != null ) {
             Enumeration keys = dictionary.keys();
             while ( keys.hasMoreElements() ) {
-                Component label = (Component)dictionary.get( keys.nextElement() );
+                JComponent label = (JComponent) dictionary.get(keys.nextElement());
                 widest = Math.max( label.getPreferredSize().width, widest );
             }
         }
@@ -777,7 +764,7 @@
         if ( dictionary != null ) {
             Enumeration keys = dictionary.keys();
             while ( keys.hasMoreElements() ) {
-                Component label = (Component)dictionary.get( keys.nextElement() );
+                JComponent label = (JComponent) dictionary.get(keys.nextElement());
                 tallest = Math.max( label.getPreferredSize().height, tallest );
             }
         }
@@ -1001,22 +988,14 @@
 
     public void paintTicks(Graphics g)  {
         Rectangle tickBounds = tickRect;
-        int i;
-        int maj, min, max;
-        int w = tickBounds.width;
-        int h = tickBounds.height;
-        int centerEffect, tickHeight;
 
         g.setColor(DefaultLookup.getColor(slider, this, "Slider.tickColor", Color.black));
 
-        maj = slider.getMajorTickSpacing();
-        min = slider.getMinorTickSpacing();
-
         if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
            g.translate( 0, tickBounds.y);
 
             int value = slider.getMinimum();
-            int xPos = 0;
+            int xPos;
 
             if ( slider.getMinorTickSpacing() > 0 ) {
                 while ( value <= slider.getMaximum() ) {
@@ -1042,7 +1021,7 @@
            g.translate(tickBounds.x, 0);
 
             int value = slider.getMinimum();
-            int yPos = 0;
+            int yPos;
 
             if ( slider.getMinorTickSpacing() > 0 ) {
                 int offset = 0;
@@ -1111,10 +1090,19 @@
                 Integer key = (Integer)keys.nextElement();
                 int value = key.intValue();
                 if (value >= minValue && value <= maxValue) {
-                    Component label = (Component)dictionary.get( key );
-                    if (label instanceof JComponent) {
-                        ((JComponent)label).setEnabled(enabled);
+                    JComponent label = (JComponent) dictionary.get(key);
+                    label.setEnabled(enabled);
+
+                    if (label instanceof JLabel) {
+                        Icon icon = label.isEnabled() ? ((JLabel) label).getIcon() : ((JLabel) label).getDisabledIcon();
+
+                        if (icon instanceof ImageIcon) {
+                            // Register Slider as an image observer. It allows to catch notifications about
+                            // image changes (e.g. gif animation)
+                            Toolkit.getDefaultToolkit().checkImage(((ImageIcon) icon).getImage(), -1, -1, slider);
+                        }
                     }
+
                     if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
                         g.translate( 0, labelBounds.y );
                         paintHorizontalLabel( g, value, label );
@@ -1364,7 +1352,7 @@
         int min = slider.getMinimum();
         int max = slider.getMaximum();
         double valueRange = (double)max - (double)min;
-        double pixelsPerValue = (double)trackHeight / (double)valueRange;
+        double pixelsPerValue = (double)trackHeight / valueRange;
         int trackBottom = trackY + (trackHeight - 1);
         int yPosition;
 
@@ -1715,7 +1703,7 @@
         * of the thumb relative to the origin of the track.
         */
         public void mouseDragged(MouseEvent e) {
-            int thumbMiddle = 0;
+            int thumbMiddle;
 
             if (!slider.isEnabled()) {
                 return;
@@ -1841,7 +1829,7 @@
         public void componentResized(ComponentEvent e)  {
             getHandler().componentResized(e);
         }
-    };
+    }
 
     /**
      * Focus-change listener.
@@ -1903,7 +1891,7 @@
             return b;
         }
 
-    };
+    }
 
 
     /**
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Wed Jun 25 16:44:55 2008 -0700
@@ -853,9 +853,7 @@
                      "ESCAPE", "cancelSelection",
                      "F2", "editFileName",
                      "F5", "refresh",
-                     "BACK_SPACE", "Go Up",
-                     "ENTER", "approveSelection",
-                "ctrl ENTER", "approveSelection"
+                     "BACK_SPACE", "Go Up"
                  }),
 
 
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java	Wed Jun 25 16:44:55 2008 -0700
@@ -25,26 +25,17 @@
 
 package javax.swing.plaf.synth;
 
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Adjustable;
 import java.awt.event.*;
 import java.awt.Graphics;
 import java.awt.Dimension;
-import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Rectangle;
 import java.awt.Point;
 import java.awt.Insets;
-import java.awt.Color;
-import java.awt.IllegalComponentStateException;
-import java.awt.Polygon;
 import java.beans.*;
 import java.util.Dictionary;
 import java.util.Enumeration;
-import javax.swing.border.AbstractBorder;
 import javax.swing.*;
-import javax.swing.event.*;
 import javax.swing.plaf.*;
 import javax.swing.plaf.basic.BasicSliderUI;
 import sun.swing.plaf.synth.SynthUI;
@@ -203,8 +194,7 @@
                 centerY += valueHeight + 2;
                 centerY += trackHeight + trackInsets.top + trackInsets.bottom;
                 centerY += tickHeight + 2;
-                Component label = (Component)slider.getLabelTable().
-                                   elements().nextElement();
+                JComponent label = (JComponent) slider.getLabelTable().elements().nextElement();
                 Dimension pref = label.getPreferredSize();
                 return centerY + label.getBaseline(pref.width, pref.height);
             }
@@ -226,8 +216,7 @@
                     int trackHeight = contentHeight - valueHeight;
                     int yPosition = yPositionForValue(value.intValue(), trackY,
                                                       trackHeight);
-                    Component label = (Component)slider.getLabelTable().
-                            get(value);
+                    JComponent label = (JComponent) slider.getLabelTable().get(value);
                     Dimension pref = label.getPreferredSize();
                     return yPosition - pref.height / 2 +
                             label.getBaseline(pref.width, pref.height);
@@ -434,16 +423,14 @@
     /**
      * Calculates the pad for the label at the specified index.
      *
-     * @param index index of the label to calculate pad for.
+     * @param i index of the label to calculate pad for.
      * @return padding required to keep label visible.
      */
     private int getPadForLabel(int i) {
-        Dictionary dictionary = slider.getLabelTable();
         int pad = 0;
 
-        Object o = dictionary.get(i);
-        if (o != null) {
-            Component c = (Component)o;
+        JComponent c = (JComponent) slider.getLabelTable().get(i);
+        if (c != null) {
             int centerX = xPositionForValue(i);
             int cHalfWidth = c.getPreferredSize().width / 2;
             if (centerX - cHalfWidth < insetCache.left) {
@@ -500,8 +487,6 @@
         }
     }
 
-    private static Rectangle unionRect = new Rectangle();
-
     public void setThumbLocation(int x, int y) {
         super.setThumbLocation(x, y);
         // Value rect is tied to the thumb location.  We need to repaint when
@@ -544,7 +529,7 @@
                 trackBorder;
         int trackLength = trackBottom - trackTop;
         double valueRange = (double)max - (double)min;
-        double pixelsPerValue = (double)trackLength / (double)valueRange;
+        double pixelsPerValue = (double)trackLength / valueRange;
         int yPosition;
 
         if (!drawInverted()) {
@@ -802,8 +787,7 @@
         }
 
         public void mouseDragged(MouseEvent e) {
-            SynthScrollBarUI ui;
-            int thumbMiddle = 0;
+            int thumbMiddle;
 
             if (!slider.isEnabled()) {
                 return;
--- a/jdk/src/share/classes/javax/swing/text/FlowView.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/text/FlowView.java	Wed Jun 25 16:44:55 2008 -0700
@@ -333,17 +333,24 @@
      * @since 1.3
      */
     public static class FlowStrategy {
-        int damageStart = Integer.MAX_VALUE;
+        Position damageStart = null;
         Vector<View> viewBuffer;
 
         void addDamage(FlowView fv, int offset) {
             if (offset >= fv.getStartOffset() && offset < fv.getEndOffset()) {
-                damageStart = Math.min(damageStart, offset);
+                if (damageStart == null || offset < damageStart.getOffset()) {
+                    try {
+                        damageStart = fv.getDocument().createPosition(offset);
+                    } catch (BadLocationException e) {
+                        // shouldn't happen since offset is inside view bounds
+                        assert(false);
+                    }
+                }
             }
         }
 
         void unsetDamage() {
-            damageStart = Integer.MAX_VALUE;
+            damageStart = null;
         }
 
         /**
@@ -438,13 +445,14 @@
             int p1 = fv.getEndOffset();
 
             if (fv.majorAllocValid) {
-                if (damageStart == Integer.MAX_VALUE) {
+                if (damageStart == null) {
                     return;
                 }
                 // In some cases there's no view at position damageStart, so
                 // step back and search again. See 6452106 for details.
-                while ((rowIndex = fv.getViewIndexAtPosition(damageStart)) < 0) {
-                    damageStart--;
+                int offset = damageStart.getOffset();
+                while ((rowIndex = fv.getViewIndexAtPosition(offset)) < 0) {
+                    offset--;
                 }
                 if (rowIndex > 0) {
                     rowIndex--;
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolder.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolder.java	Wed Jun 25 16:44:55 2008 -0700
@@ -25,6 +25,7 @@
 
 package sun.awt.shell;
 
+import javax.swing.*;
 import java.awt.Image;
 import java.awt.Toolkit;
 import java.io.*;
@@ -37,6 +38,10 @@
  */
 
 public abstract class ShellFolder extends File {
+    private static final String COLUMN_NAME = "FileChooser.fileNameHeaderText";
+    private static final String COLUMN_SIZE = "FileChooser.fileSizeHeaderText";
+    private static final String COLUMN_DATE = "FileChooser.fileDateHeaderText";
+
     protected ShellFolder parent;
 
     /**
@@ -268,8 +273,45 @@
 
     // Override File methods
 
-    public static void sortFiles(List files) {
-        shellFolderManager.sortFiles(files);
+    public static void sort(List<? extends File> files) {
+        if (files == null || files.size() <= 1) {
+            return;
+        }
+
+        // Check that we can use the ShellFolder.sortChildren() method:
+        //   1. All files have the same non-null parent
+        //   2. All files is ShellFolders
+        File commonParent = null;
+
+        for (File file : files) {
+            File parent = file.getParentFile();
+
+            if (parent == null || !(file instanceof ShellFolder)) {
+                commonParent = null;
+
+                break;
+            }
+
+            if (commonParent == null) {
+                commonParent = parent;
+            } else {
+                if (commonParent != parent && !commonParent.equals(parent)) {
+                    commonParent = null;
+
+                    break;
+                }
+            }
+        }
+
+        if (commonParent instanceof ShellFolder) {
+            ((ShellFolder) commonParent).sortChildren(files);
+        } else {
+            Collections.sort(files, FILE_COMPARATOR);
+        }
+    }
+
+    public void sortChildren(List<? extends File> files) {
+        Collections.sort(files, FILE_COMPARATOR);
     }
 
     public boolean isAbsolute() {
@@ -356,18 +398,131 @@
     }
 
     public static ShellFolderColumnInfo[] getFolderColumns(File dir) {
-        return shellFolderManager.getFolderColumns(dir);
-    }
+        ShellFolderColumnInfo[] columns = null;
+
+        if (dir instanceof ShellFolder) {
+            columns = ((ShellFolder) dir).getFolderColumns();
+        }
 
-    public static Object getFolderColumnValue(File file, int column) {
-        return shellFolderManager.getFolderColumnValue(file, column);
+        if (columns == null) {
+            columns = new ShellFolderColumnInfo[]{
+                    new ShellFolderColumnInfo(COLUMN_NAME, 150,
+                            SwingConstants.LEADING, true, null,
+                            FILE_COMPARATOR),
+                    new ShellFolderColumnInfo(COLUMN_SIZE, 75,
+                            SwingConstants.RIGHT, true, null,
+                            DEFAULT_COMPARATOR, true),
+                    new ShellFolderColumnInfo(COLUMN_DATE, 130,
+                            SwingConstants.LEADING, true, null,
+                            DEFAULT_COMPARATOR, true)
+            };
+        }
+
+        return columns;
     }
 
     public ShellFolderColumnInfo[] getFolderColumns() {
         return null;
     }
 
+    public static Object getFolderColumnValue(File file, int column) {
+        if (file instanceof ShellFolder) {
+            Object value = ((ShellFolder)file).getFolderColumnValue(column);
+            if (value != null) {
+                return value;
+            }
+        }
+
+        if (file == null || !file.exists()) {
+            return null;
+        }
+
+        switch (column) {
+            case 0:
+                // By default, file name will be rendered using getSystemDisplayName()
+                return file;
+
+            case 1: // size
+                return file.isDirectory() ? null : Long.valueOf(file.length());
+
+            case 2: // date
+                if (isFileSystemRoot(file)) {
+                    return null;
+                }
+                long time = file.lastModified();
+                return (time == 0L) ? null : new Date(time);
+
+            default:
+                return null;
+        }
+    }
+
     public Object getFolderColumnValue(int column) {
         return null;
     }
+
+    /**
+     * Provides a default comparator for the default column set
+     */
+    private static final Comparator DEFAULT_COMPARATOR = new Comparator() {
+        public int compare(Object o1, Object o2) {
+            int gt;
+
+            if (o1 == null && o2 == null) {
+                gt = 0;
+            } else if (o1 != null && o2 == null) {
+                gt = 1;
+            } else if (o1 == null && o2 != null) {
+                gt = -1;
+            } else if (o1 instanceof Comparable) {
+                gt = ((Comparable) o1).compareTo(o2);
+            } else {
+                gt = 0;
+            }
+
+            return gt;
+        }
+    };
+
+    private static final Comparator<File> FILE_COMPARATOR = new Comparator<File>() {
+        public int compare(File f1, File f2) {
+            ShellFolder sf1 = null;
+            ShellFolder sf2 = null;
+
+            if (f1 instanceof ShellFolder) {
+                sf1 = (ShellFolder) f1;
+                if (sf1.isFileSystem()) {
+                    sf1 = null;
+                }
+            }
+            if (f2 instanceof ShellFolder) {
+                sf2 = (ShellFolder) f2;
+                if (sf2.isFileSystem()) {
+                    sf2 = null;
+                }
+            }
+
+            if (sf1 != null && sf2 != null) {
+                return sf1.compareTo(sf2);
+            } else if (sf1 != null) {
+                // Non-file shellfolders sort before files
+                return -1;
+            } else if (sf2 != null) {
+                return 1;
+            } else {
+                String name1 = f1.getName();
+                String name2 = f2.getName();
+
+                // First ignore case when comparing
+                int diff = name1.compareToIgnoreCase(name2);
+                if (diff != 0) {
+                    return diff;
+                } else {
+                    // May differ in case (e.g. "mail" vs. "Mail")
+                    // We need this test for consistent sorting
+                    return name1.compareTo(name2);
+                }
+            }
+        }
+    };
 }
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolderManager.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolderManager.java	Wed Jun 25 16:44:55 2008 -0700
@@ -27,8 +27,6 @@
 
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.util.*;
-import javax.swing.SwingConstants;
 
 /**
  * @author Michael Martak
@@ -36,10 +34,6 @@
  */
 
 class ShellFolderManager {
-    private static final String COLUMN_NAME = "FileChooser.fileNameHeaderText";
-    private static final String COLUMN_SIZE = "FileChooser.fileSizeHeaderText";
-    private static final String COLUMN_DATE = "FileChooser.fileDateHeaderText";
-
     /**
      * Create a shell folder from a file.
      * Override to return machine-dependent behavior.
@@ -107,142 +101,4 @@
         }
         return (dir.getParentFile() == null);
     }
-
-    public void sortFiles(List files) {
-        Collections.sort(files, fileComparator);
-    }
-
-    private Comparator fileComparator = new Comparator() {
-        public int compare(Object a, Object b) {
-            return compare((File)a, (File)b);
-        }
-
-        public int compare(File f1, File f2) {
-            ShellFolder sf1 = null;
-            ShellFolder sf2 = null;
-
-            if (f1 instanceof ShellFolder) {
-                sf1 = (ShellFolder)f1;
-                if (sf1.isFileSystem()) {
-                    sf1 = null;
-                }
-            }
-            if (f2 instanceof ShellFolder) {
-                sf2 = (ShellFolder)f2;
-                if (sf2.isFileSystem()) {
-                    sf2 = null;
-                }
-            }
-
-            if (sf1 != null && sf2 != null) {
-                return sf1.compareTo(sf2);
-            } else if (sf1 != null) {
-                return -1;      // Non-file shellfolders sort before files
-            } else if (sf2 != null) {
-                return 1;
-            } else {
-                String name1 = f1.getName();
-                String name2 = f2.getName();
-
-                // First ignore case when comparing
-                int diff = name1.toLowerCase().compareTo(name2.toLowerCase());
-                if (diff != 0) {
-                    return diff;
-                } else {
-                    // May differ in case (e.g. "mail" vs. "Mail")
-                    // We need this test for consistent sorting
-                    return name1.compareTo(name2);
-                }
-            }
-        }
-    };
-
-    public ShellFolderColumnInfo[] getFolderColumns(File dir) {
-        ShellFolderColumnInfo[] columns = null;
-
-        if (dir instanceof ShellFolder) {
-            columns = ((ShellFolder)dir).getFolderColumns();
-        }
-
-        if (columns == null) {
-            columns = new ShellFolderColumnInfo[]{
-                new ShellFolderColumnInfo(COLUMN_NAME, 150,
-                        SwingConstants.LEADING, true, null,
-                        fileComparator),
-                new ShellFolderColumnInfo(COLUMN_SIZE, 75,
-                        SwingConstants.RIGHT, true, null,
-                        ComparableComparator.getInstance(), true),
-                new ShellFolderColumnInfo(COLUMN_DATE, 130,
-                        SwingConstants.LEADING, true, null,
-                        ComparableComparator.getInstance(), true)
-            };
-        }
-
-        return columns;
-    }
-
-    public Object getFolderColumnValue(File file, int column) {
-        if (file instanceof ShellFolder) {
-            Object value = ((ShellFolder)file).getFolderColumnValue(column);
-            if (value != null) {
-                return value;
-            }
-        }
-
-        if (file == null || !file.exists()) {
-            return null;
-        }
-
-        switch (column) {
-            case 0:
-                // By default, file name will be rendered using getSystemDisplayName()
-                return file;
-
-            case 1: // size
-                return file.isDirectory() ? null : new Long(file.length());
-
-            case 2: // date
-                if (isFileSystemRoot(file)) {
-                    return null;
-                }
-                long time = file.lastModified();
-                return (time == 0L) ? null : new Date(time);
-
-            default:
-                return null;
-        }
-    }
-
-    /**
-     * This class provides a default comparator for the default column set
-     */
-    private static class ComparableComparator implements Comparator {
-        private static Comparator instance;
-
-        public static Comparator getInstance() {
-            if (instance == null) {
-                instance = new ComparableComparator();
-            }
-            return instance;
-        }
-
-        public int compare(Object o1, Object o2) {
-            int gt;
-
-            if (o1 == null && o2 == null) {
-                gt = 0;
-            } else if (o1 != null && o2 == null) {
-                gt = 1;
-            } else if (o1 == null && o2 != null) {
-                gt = -1;
-            } else if (o1 instanceof Comparable) {
-                gt = ((Comparable) o1).compareTo(o2);
-            } else {
-                gt = 0;
-            }
-
-            return gt;
-        }
-    }
-
 }
--- a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java	Wed Jun 25 16:44:55 2008 -0700
@@ -306,7 +306,7 @@
      * <code>java.io.File</code> instead. If not, then the object depends
      * on native PIDL state and should not be serialized.
      *
-     * @returns a <code>java.io.File</code> replacement object. If the folder
+     * @return a <code>java.io.File</code> replacement object. If the folder
      * is a not a normal directory, then returns the first non-removable
      * drive (normally "C:\").
      */
@@ -605,10 +605,10 @@
         // parent so we have an IShellFolder to query.
         long pIShellFolder = getIShellFolder();
         // Now we can enumerate the objects in this folder.
-        ArrayList list = new ArrayList();
+        ArrayList<Win32ShellFolder2> list = new ArrayList<Win32ShellFolder2>();
         long pEnumObjects = getEnumObjects(pIShellFolder, includeHiddenFiles);
         if (pEnumObjects != 0) {
-            long childPIDL = 0;
+            long childPIDL;
             int testedAttrs = ATTRIB_FILESYSTEM | ATTRIB_FILESYSANCESTOR;
             do {
                 if (Thread.currentThread().isInterrupted()) {
@@ -635,7 +635,7 @@
             } while (childPIDL != 0);
             releaseEnumObjects(pEnumObjects);
         }
-        return (ShellFolder[])list.toArray(new ShellFolder[list.size()]);
+        return list.toArray(new ShellFolder[list.size()]);
     }
 
 
@@ -648,7 +648,7 @@
         long pIShellFolder = getIShellFolder();
         long pEnumObjects =  getEnumObjects(pIShellFolder, true);
         Win32ShellFolder2 child = null;
-        long childPIDL = 0;
+        long childPIDL;
 
         while ((childPIDL = getNextChild(pEnumObjects)) != 0) {
             if (getAttributes0(pIShellFolder, childPIDL, ATTRIB_FILESYSTEM) != 0) {
@@ -983,7 +983,7 @@
                             ? SwingConstants.CENTER
                                 : SwingConstants.LEADING);
 
-                    column.setComparator(new ColumnComparator(i));
+                    column.setComparator(new ColumnComparator(getIShellFolder(), i));
 
                     notNullColumns.add(column);
                 }
@@ -1002,22 +1002,29 @@
 
     private native Object doGetColumnValue(long parentIShellFolder2, long childPIDL, int columnIdx);
 
-    private native int compareIDsByColumn(long pParentIShellFolder, long pidl1, long pidl2, int columnIdx);
+    private static native int compareIDsByColumn(long pParentIShellFolder, long pidl1, long pidl2, int columnIdx);
 
 
-    private class ColumnComparator implements Comparator {
+    public void sortChildren(List<? extends File> files) {
+        Collections.sort(files, new ColumnComparator(getIShellFolder(), 0));
+    }
+
+    private static class ColumnComparator implements Comparator<File> {
+        private final long parentIShellFolder;
+
         private final int columnIdx;
 
-        public ColumnComparator(int columnIdx) {
+        public ColumnComparator(long parentIShellFolder, int columnIdx) {
+            this.parentIShellFolder = parentIShellFolder;
             this.columnIdx = columnIdx;
         }
 
         // compares 2 objects within this folder by the specified column
-        public int compare(Object o, Object o1) {
+        public int compare(File o, File o1) {
             if (o instanceof Win32ShellFolder2
                     && o1 instanceof Win32ShellFolder2) {
                 // delegates comparison to native method
-                return compareIDsByColumn(getIShellFolder(),
+                return compareIDsByColumn(parentIShellFolder,
                         ((Win32ShellFolder2) o).getRelativePIDL(),
                         ((Win32ShellFolder2) o1).getRelativePIDL(),
                         columnIdx);
--- a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java	Fri Jun 20 16:34:34 2008 -0700
+++ b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java	Wed Jun 25 16:44:55 2008 -0700
@@ -234,11 +234,11 @@
                         // Add third level for "My Computer"
                         if (folder.equals(drives)) {
                             File[] thirdLevelFolders = folder.listFiles();
-                            if (thirdLevelFolders != null) {
-                                Arrays.sort(thirdLevelFolders, driveComparator);
-                                for (File thirdLevelFolder : thirdLevelFolders) {
-                                    folders.add(thirdLevelFolder);
-                                }
+                            if (thirdLevelFolders != null && thirdLevelFolders.length > 0) {
+                                List<File> thirdLevelFoldersList = Arrays.asList(thirdLevelFolders);
+
+                                folder.sortChildren(thirdLevelFoldersList);
+                                folders.addAll(thirdLevelFoldersList);
                             }
                         }
                     }
@@ -362,27 +362,6 @@
         return false;
     }
 
-    private Comparator driveComparator = new Comparator() {
-        public int compare(Object o1, Object o2) {
-            Win32ShellFolder2 shellFolder1 = (Win32ShellFolder2) o1;
-            Win32ShellFolder2 shellFolder2 = (Win32ShellFolder2) o2;
-
-            // Put drives at first
-            boolean isDrive1 = shellFolder1.getPath().endsWith(":\\");
-
-            if (isDrive1 ^ shellFolder2.getPath().endsWith(":\\")) {
-                return isDrive1 ? -1 : 1;
-            } else {
-                return shellFolder1.getPath().compareTo(shellFolder2.getPath());
-            }
-        }
-    };
-
-
-    public void sortFiles(List files) {
-        Collections.sort(files, fileComparator);
-    }
-
     private static List topFolderList = null;
     static int compareShellFolders(Win32ShellFolder2 sf1, Win32ShellFolder2 sf2) {
         boolean special1 = sf1.isSpecial();
@@ -418,19 +397,9 @@
         return compareNames(sf1.getAbsolutePath(), sf2.getAbsolutePath());
     }
 
-    static int compareFiles(File f1, File f2) {
-        if (f1 instanceof Win32ShellFolder2) {
-            return f1.compareTo(f2);
-        }
-        if (f2 instanceof Win32ShellFolder2) {
-            return -1 * f2.compareTo(f1);
-        }
-        return compareNames(f1.getName(), f2.getName());
-    }
-
     static int compareNames(String name1, String name2) {
         // First ignore case when comparing
-        int diff = name1.toLowerCase().compareTo(name2.toLowerCase());
+        int diff = name1.compareToIgnoreCase(name2);
         if (diff != 0) {
             return diff;
         } else {
@@ -439,14 +408,4 @@
             return name1.compareTo(name2);
         }
     }
-
-    private Comparator fileComparator = new Comparator() {
-        public int compare(Object a, Object b) {
-            return compare((File)a, (File)b);
-        }
-
-        public int compare(File f1, File f2) {
-            return compareFiles(f1, f2);
-        }
-    };
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/java_io_File.java	Wed Jun 25 16:44:55 2008 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6708550
+ * @summary Tests File encoding
+ * @author Sergey Malenkov
+ */
+
+import java.io.File;
+
+public final class java_io_File extends AbstractTest<File> {
+    public static void main(String[] args) {
+        new java_io_File().test(true);
+    }
+
+    @Override
+    protected File getObject() {
+        return new File("test.txt"); // NON-NLS: local file
+    }
+
+    @Override
+    protected File getAnotherObject() {
+        return new File("/pub/demo/"); // NON-NLS: path
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/6694823/bug6694823.java	Wed Jun 25 16:44:55 2008 -0700
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6694823
+ * @summary Checks that popup menu cannot be partially hidden
+ * by the task bar in applets.
+ * @author Mikhail Lapshin
+ * @run main bug6694823
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import sun.awt.SunToolkit;
+
+public class bug6694823 {
+    private static JFrame frame;
+    private static JPopupMenu popup;
+    private static SunToolkit toolkit;
+    private static Insets screenInsets;
+
+    public static void main(String[] args) throws Exception {
+        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                createGui();
+            }
+        });
+
+        // Get screen insets
+        screenInsets = toolkit.getScreenInsets(frame.getGraphicsConfiguration());
+        if (screenInsets.bottom == 0) {
+            // This test is only for configurations with taskbar on the bottom
+            return;
+        }
+
+        // Show popup as if from a standalone application
+        // The popup should be able to overlap the task bar
+        showPopup(false);
+
+        // Emulate applet security restrictions
+        toolkit.realSync();
+        System.setSecurityManager(new SecurityManager());
+
+        // Show popup as if from an applet
+        // The popup shouldn't overlap the task bar. It should be shifted up.
+        showPopup(true);
+
+        toolkit.realSync();
+        System.out.println("Test passed!");
+        frame.dispose();
+    }
+
+    private static void createGui() {
+        frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+        frame.setUndecorated(true);
+
+        popup = new JPopupMenu("Menu");
+        for (int i = 0; i < 7; i++) {
+            popup.add(new JMenuItem("MenuItem"));
+        }
+        JPanel panel = new JPanel();
+        panel.setComponentPopupMenu(popup);
+        frame.add(panel);
+
+        frame.setSize(200, 200);
+    }
+
+    private static void showPopup(final boolean shouldBeShifted) {
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                // Place frame just above the task bar
+                Dimension screenSize = toolkit.getScreenSize();
+                frame.setLocation(screenSize.width / 2,
+                        screenSize.height - frame.getHeight() - screenInsets.bottom);
+                frame.setVisible(true);
+
+                // Place popup over the task bar
+                Point frameLoc = frame.getLocationOnScreen();
+                int x = 0;
+                int y = frame.getHeight()
+                        - popup.getPreferredSize().height + screenInsets.bottom;
+                popup.show(frame, x, y);
+
+                if (shouldBeShifted) {
+                    if (popup.getLocationOnScreen()
+                            .equals(new Point(frameLoc.x, frameLoc.y + y))) {
+                        throw new RuntimeException("Popup is not shifted");
+                    }
+                } else {
+                    if (!popup.getLocationOnScreen()
+                            .equals(new Point(frameLoc.x, frameLoc.y + y))) {
+                        throw new RuntimeException("Popup is unexpectedly shifted");
+                    }
+                }
+                popup.setVisible(false);
+            }
+        });
+    }
+}
Binary file jdk/test/javax/swing/JSlider/4987336/box.gif has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JSlider/4987336/bug4987336.html	Wed Jun 25 16:44:55 2008 -0700
@@ -0,0 +1,9 @@
+<html>
+<body>
+<applet  code="bug4987336.class" width=600 height=400></applet>
+There are four Sliders. Each of them has a label with animated gif (a cup of coffee)
+and a label with static image.
+
+Check that for every LAF animation works for all Sliders. 
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JSlider/4987336/bug4987336.java	Wed Jun 25 16:44:55 2008 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @bug 4987336
+   @summary JSlider doesn't show label's animated icon.
+   @author Pavel Porvatov
+   @run applet/manual=done bug4987336.html
+*/
+
+import javax.swing.*;
+import javax.swing.border.TitledBorder;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Hashtable;
+
+public class bug4987336 extends JApplet {
+    private static final String IMAGE_RES = "box.gif";
+
+    private static final String ANIM_IMAGE_RES = "cupanim.gif";
+
+    public void init() {
+        JPanel pnLafs = new JPanel();
+        pnLafs.setLayout(new BoxLayout(pnLafs, BoxLayout.Y_AXIS));
+
+        ButtonGroup group = new ButtonGroup();
+
+        pnLafs.setBorder(new TitledBorder("Available Lafs"));
+
+        for (UIManager.LookAndFeelInfo lafInfo : UIManager.getInstalledLookAndFeels()) {
+            LafRadioButton comp = new LafRadioButton(lafInfo);
+
+            pnLafs.add(comp);
+            group.add(comp);
+        }
+
+        JPanel pnContent = new JPanel();
+
+        pnContent.setLayout(new BoxLayout(pnContent, BoxLayout.Y_AXIS));
+
+        pnContent.add(pnLafs);
+        pnContent.add(createSlider(true, IMAGE_RES, IMAGE_RES, ANIM_IMAGE_RES, ANIM_IMAGE_RES));
+        pnContent.add(createSlider(false, IMAGE_RES, IMAGE_RES, ANIM_IMAGE_RES, ANIM_IMAGE_RES));
+        pnContent.add(createSlider(true, ANIM_IMAGE_RES, null, IMAGE_RES, IMAGE_RES));
+        pnContent.add(createSlider(false, ANIM_IMAGE_RES, null, IMAGE_RES, IMAGE_RES));
+
+        getContentPane().add(new JScrollPane(pnContent));
+    }
+
+    private static JSlider createSlider(boolean enabled,
+                                        String firstEnabledImage, String firstDisabledImage,
+                                        String secondEnabledImage, String secondDisabledImage) {
+        Hashtable<Integer, JComponent> dictionary = new Hashtable<Integer, JComponent>();
+
+        dictionary.put(0, createLabel(firstEnabledImage, firstDisabledImage));
+        dictionary.put(1, createLabel(secondEnabledImage, secondDisabledImage));
+
+        JSlider result = new JSlider(0, 1);
+
+        result.setLabelTable(dictionary);
+        result.setPaintLabels(true);
+        result.setEnabled(enabled);
+
+        return result;
+    }
+
+    private static JLabel createLabel(String enabledImage, String disabledImage) {
+        ImageIcon enabledIcon = enabledImage == null ? null :
+                new ImageIcon(bug4987336.class.getResource(enabledImage));
+
+        ImageIcon disabledIcon = disabledImage == null ? null :
+                new ImageIcon(bug4987336.class.getResource(disabledImage));
+
+        JLabel result = new JLabel(enabledImage == null && disabledImage == null ? "No image" : "Image",
+                enabledIcon, SwingConstants.LEFT);
+
+        result.setDisabledIcon(disabledIcon);
+
+        return result;
+    }
+
+    private class LafRadioButton extends JRadioButton {
+        public LafRadioButton(final UIManager.LookAndFeelInfo lafInfo) {
+            super(lafInfo.getName(), lafInfo.getName().equals(UIManager.getLookAndFeel().getName()));
+
+            addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    try {
+                        UIManager.setLookAndFeel(lafInfo.getClassName());
+
+                        SwingUtilities.updateComponentTreeUI(bug4987336.this);
+                    } catch (Exception ex) {
+                        // Ignore such errors
+                        System.out.println("Cannot set LAF " + lafInfo.getName());
+                    }
+                }
+            });
+        }
+    }
+}
Binary file jdk/test/javax/swing/JSlider/4987336/cupanim.gif has changed