# HG changeset patch # User rupashka # Date 1210177592 -14400 # Node ID 9c414b00e0076974c60b513c075063a1e4249462 # Parent 435cd1cc42b664d4b37b3544080f3ab09499a712 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 diff -r 435cd1cc42b6 -r 9c414b00e007 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);