This fixes the extravagant filechooser size. I simply have set the
preferredSize on the filelist panel to a reasonable value. It is not yet
perfect, the list shouldn't scroll vertically. I tried to set a
scrollbar policy to VERTICAL_SCROLLBAR_NEVER, but that makes the list
unusable again, since the JList doesn't seem to adapt correctly.

2006-02-28  Roman Kennke  <[EMAIL PROTECTED]>

        PR classpath/25675
        * javax/swing/JList.java
        (getPreferredScrollableViewportSize): Restored specified
behaviour.
        * javax/swing/plaf/metal/MetalFileChooserUI.java
        (createList): Set filelist panel's preferredSize, so that it
doesn't
        get size into infinity for big lists.

/Roman
Index: javax/swing/JList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JList.java,v
retrieving revision 1.46
diff -u -r1.46 JList.java
--- javax/swing/JList.java	28 Feb 2006 18:42:36 -0000	1.46
+++ javax/swing/JList.java	28 Feb 2006 20:13:43 -0000
@@ -1793,17 +1793,8 @@
     //If the layout orientation is not VERTICAL, then this will 
     //return the value from getPreferredSize. The current ListUI is 
     //expected to override getPreferredSize to return an appropriate value.
-    int orient = getLayoutOrientation();
-    Dimension pref = getPreferredSize();
-    if (orient == VERTICAL_WRAP)
-      {
-        if (fixedCellWidth == -1)
-          return new Dimension(getCellBounds(0, 0).width * 3, pref.height);
-        else
-          return new Dimension(fixedCellWidth, pref.height);
-      }
-    if (orient != VERTICAL)
-      return pref;        
+    if (getLayoutOrientation() != VERTICAL)
+      return getPreferredSize();        
 
     int size = getModel().getSize();
     
Index: javax/swing/plaf/metal/MetalFileChooserUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java,v
retrieving revision 1.21
diff -u -r1.21 MetalFileChooserUI.java
--- javax/swing/plaf/metal/MetalFileChooserUI.java	27 Jan 2006 10:39:06 -0000	1.21
+++ javax/swing/plaf/metal/MetalFileChooserUI.java	28 Feb 2006 20:13:43 -0000
@@ -1555,7 +1555,10 @@
         scrollPane.getViewport().setView(fileList);
       }
     fileListPanel.add(scrollPane);
-
+    // This size was determined using BeanShell and dumping the JFileChooser
+    // component hierarchy. Sun has an internal FilePane class in there, but
+    // that probably doesn't matter atm.
+    fileListPanel.setPreferredSize(new Dimension(405, 135));
     return fileListPanel;
   }
   

Reply via email to