JDK-5091302 : Not able to select System drive in windows when using JFileChooser with all opt
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-08-24
  • Updated: 2006-11-06
  • Resolved: 2004-12-01
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.
JDK 6
6 b14Fixed
Related Reports
Relates :  
Description
Bug Description:
---------------
Not able open System Drives in windows using JFileChooser with "FILES_AND_DIRECTORIES" option.

JDK-Info:
--------
java version "1.5.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)

Steps to Reproduce:
-------------------
1. Install jdk1.5.0 b63 in WindowsXP System.
2. Compile and run the attached Test.java file with following command line argument 0 or 1 or 2(java Test 0)
3.Click "Click Me" button JFileChooser will open

0 = FILES_ONLY
1 = FILES_AND_DIRECTORIES
2 = DIRECTORIES_ONLY

In all the three cases try selecting the MyComputer in "Look In" combobox then using tab select any of the system drive for example "C" Drive or "D" Drive listed and click enter button in KeyBoard.

For option 0 and 2 the system drive will list the files and folder when the drive is selected and Enter Key is pressed but its not working only with "FILES_AND_DIRECTORIES" option.


###@###.### 2004-08-24

Comments
SUGGESTED FIX *** /net/crown/export1/kve/dragon/webrev/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java- Tue Sep 28 17:12:58 2004 --- WindowsFileChooserUI.java Tue Sep 28 13:16:34 2004 *************** *** 675,681 **** return null; } else { JFileChooser fc = getFileChooser(); ! if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) { return file.getPath(); } else { return file.getName(); --- 675,682 ---- return null; } else { JFileChooser fc = getFileChooser(); ! if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) || ! (fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled() && fc.getFileSystemView().isFileSystemRoot(file))){ return file.getPath(); } else { return file.getName(); *** /net/crown/export1/kve/dragon/webrev/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java- Tue Sep 28 17:12:58 2004 --- MetalFileChooserUI.java Wed Sep 22 19:32:35 2004 *************** *** 579,585 **** return null; } else { JFileChooser fc = getFileChooser(); ! if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) { return file.getPath(); } else { return file.getName(); --- 579,586 ---- return null; } else { JFileChooser fc = getFileChooser(); ! if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) || ! (fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled() && fc.getFileSystemView().isFileSystemRoot(file))) { return file.getPath(); } else { return file.getName(); ###@###.### 11/4/04 13:52 GMT
04-11-2004

WORK AROUND Use "Look in" combo box to choose system drives ###@###.### 11/4/04 13:52 GMT
04-11-2004

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
29-09-2004

EVALUATION Reproducible with FileChooserDemo on Windows XP. ###@###.### 2004-08-24 Name: ke153230 Date: 09/28/2004 This happens because in MetalFileChooserUI's fileNameString() we return file.getName() instead of file.getPath() for file system roots in case of FILES_AND_DIRECTORIES. We need to specially handle this situation. ====================================================================== See suggested fix for the way to correct the problem. ###@###.### 11/4/04 13:52 GMT
04-11-0004