From 3abf54aa94292598e8c7495a16186405ecd43074 Mon Sep 17 00:00:00 2001 From: rupashka Date: Wed, 7 May 2008 20:26:32 +0400 Subject: [PATCH] 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 --- src/share/classes/sun/swing/FilePane.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/share/classes/sun/swing/FilePane.java b/src/share/classes/sun/swing/FilePane.java index c605a54a8..eaba7b153 100644 --- a/src/share/classes/sun/swing/FilePane.java +++ b/src/share/classes/sun/swing/FilePane.java @@ -1285,7 +1285,6 @@ public class FilePane extends JPanel implements PropertyChangeListener { int lastIndex = -1; File editFile = null; - int editX = 20; private int getEditIndex() { return lastIndex; @@ -1315,7 +1314,9 @@ public class FilePane extends JPanel implements PropertyChangeListener { * @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 @@ public class FilePane extends JPanel implements PropertyChangeListener { 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 @@ public class FilePane extends JPanel implements PropertyChangeListener { 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); -- GitLab