6635277: Incorrect text seen when creating a new folder, when selection is on the image file in JFileChooser
authorrupashka
Wed, 07 May 2008 20:26:32 +0400
changeset 464 9c414b00e007
parent 463 435cd1cc42b6
child 465 507ce3a1af17
6635277: Incorrect text seen when creating a new folder, when selection is on the image file in JFileChooser Summary: Corrected bounds of editor area Reviewed-by: loneid
jdk/src/share/classes/sun/swing/FilePane.java
--- a/jdk/src/share/classes/sun/swing/FilePane.java	Wed May 07 16:08:31 2008 +0400
+++ b/jdk/src/share/classes/sun/swing/FilePane.java	Wed May 07 20:26:32 2008 +0400
@@ -1285,7 +1285,6 @@
 
     int lastIndex = -1;
     File editFile = null;
-    int editX = 20;
 
     private int getEditIndex() {
         return lastIndex;
@@ -1315,7 +1314,9 @@
      * @param index visual index of the file to be edited
      */
     private void editFileName(int index) {
-        File currentDirectory = getFileChooser().getCurrentDirectory();
+        JFileChooser chooser = getFileChooser();
+        File currentDirectory = chooser.getCurrentDirectory();
+
         if (readOnly || !canWrite(currentDirectory)) {
             return;
         }
@@ -1332,9 +1333,15 @@
                 editCell.setNextFocusableComponent(list);
             }
             list.add(editCell);
-            editCell.setText(getFileChooser().getName(editFile));
+            editCell.setText(chooser.getName(editFile));
             ComponentOrientation orientation = list.getComponentOrientation();
             editCell.setComponentOrientation(orientation);
+
+            Icon icon = chooser.getIcon(editFile);
+
+            // PENDING - grab padding (4) below from defaults table.
+            int editX = icon == null ? 20 : icon.getIconWidth() + 4;
+
             if (orientation.isLeftToRight()) {
                 editCell.setBounds(editX + r.x, r.y, r.width - editX, r.height);
             } else {
@@ -1458,11 +1465,6 @@
             Icon icon = getFileChooser().getIcon(file);
             if (icon != null) {
                 setIcon(icon);
-
-                if (isSelected) {
-                    // PENDING - grab padding (4) below from defaults table.
-                    editX = icon.getIconWidth() + 4;
-                }
             } else {
                 if (getFileChooser().getFileSystemView().isTraversable(file)) {
                     setText(fileName+File.separator);