JDK-6438246 : File name field is mislabeled when JFileChooser is used in DIRECTORIES_ONLY mode
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-06-14
  • Updated: 2011-03-09
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other JDK 6 JDK 7
5.0u16-revFixed 5.0u17Fixed 6u27Fixed 7 b15Fixed
Related Reports
Relates :  
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.
06-03-2007