United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6438246 File name field is mislabeled when JFileChooser is used in DIRECTORIES_ONLY mode
JDK-6438246 : File name field is mislabeled when JFileChooser is used in DIRECTORIES_ONLY mode

Details
Type:
Enhancement
Submit Date:
2006-06-14
Status:
Closed
Updated Date:
2011-03-09
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
When JFileChooser dialog is opened in DIRECTORIES_ONLY mode, the field containing the selected directory path is labeled "File name:". This is very confusing for the users, especially if the dialog is used interchangeably for file and directory selection within the same application.

The options to alleviate this problem are quite limited. There isn't a more native "directory chooser" in Windows environment (4322989) available. There isn't a customization model allowing for changing of the existing labeling on the dialog (4203820). There is a hack to do that using UIManager, but that is just that.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The following snippet reproduces the problem

             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JFileChooser fc = new JFileChooser(System.getProperty("user.home"));
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.showOpenDialog(null);

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The name field should be labeled "Folder name:" or "Directory name:", whichever is right for the current platform.
ACTUAL -
The field is always labeled "File name:" regardless of the chooser's selection mode.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class DialogTest
{
   public static void main(String[] args) throws Exception
   {
      IManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      JFileChooser fc = new JFileChooser(System.getProperty("user.home"));
      fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      fc.showOpenDialog(null);
   }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
educate the end users
For Documentum this is very urgent and high priority. I very much hope we can deliver the fix in update 11 as we promised them.

                                    

Comments
EVALUATION

The bug impacts all L&Fs and also i18n. The fix requires adding another field for rendering directory name wherever appropriate. The value of the field needs to be fetched from the various L&F and locale dependent properties files.
                                     
2007-03-06



Hardware and Software, Engineered to Work Together