This patch fixes PR swing/23036 where the look-in box for JFileChoosers
wasn't displaying the correct parent directories.

Patch is attached.

2005-08-31  Anthony Balkissoon  <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicFileChooserUI.java:
        (boxEntries): Made this method package private because I added a 
        call to it from an implicitly defined listener class. Also fixed 
        indentation.
        (createPropertyChangeListener): If the returned property listener
        hears DIRECTORY_CHANGED_PROPERTY, call boxEntries() to update the
        look-in box entries.

--Tony
Index: javax/swing/plaf/basic/BasicFileChooserUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java,v
retrieving revision 1.7
diff -u -r1.7 BasicFileChooserUI.java
--- javax/swing/plaf/basic/BasicFileChooserUI.java      13 Jul 2005 23:22:31 -0000      1.7
+++ javax/swing/plaf/basic/BasicFileChooserUI.java      31 Aug 2005 19:59:22 -0000
@@ -1090,1 +1090,1 @@
   }

   // FIXME: Indent the entries in the combobox
-  private void boxEntries()
+  // Made this method package private to access it from within inner classes
+  // with better performance
+  void boxEntries()
   {
     ArrayList parentFiles = new ArrayList();
     File parent = filechooser.getCurrentDirectory();
@@ -1098,6 +1100,6 @@
       parent = filechooser.getFileSystemView().getDefaultDirectory();
     while (parent != null)
       {
-       String name = parent.getName();
-       if (name.equals(""))
-         name = parent.getAbsolutePath();
+        String name = parent.getName();
+        if (name.equals(""))
+          name = parent.getAbsolutePath();

-       parentFiles.add(parentFiles.size(), name);
-       parent = parent.getParentFile();
+        parentFiles.add(parentFiles.size(), name);
+        parent = parent.getParentFile();
       }

     if (parentFiles.size() == 0)
@@ -1509,12 +1511,12 @@
            }
          else if (e.getPropertyName().equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY))
            {
-             //boxEntries();
              filelist.clearSelection();
              filelist.revalidate();
              filelist.repaint();
              setDirectorySelected(false);
              setDirectory(filechooser.getCurrentDirectory());
+             boxEntries();
            }
          else if (e.getPropertyName().equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)
                   || e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY))
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to