JDK-6186865 : JFileChooser does not take full pathname
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2_06
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-10-29
  • Updated: 2011-02-16
  • Resolved: 2005-05-28
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.
1.4.2_09 b02Fixed
Related Reports
Relates :  
If a full pathname of a file is given then JFileChooser is unable to open this file with J2SDK1.4.2 , this works ok with J2SDK1.5

Test Case:

I have two files in different directories with the same file name.  After changing current working directory to one of them, I cannot get the other file if I manually key in the path and copy and paste the file name from the file in current working directory.

1. copy one file to another directory (copy d:\log\aaa.txt d:\aaa.txt)
2. Run the test program, which opens the JFileChooser dialog box
3. change directory to d:\
4. click on aaa.txt (to select it). In the JFileChooser dialog box the name is editable now.
5. Ctrl - c to copy the file name ("aaa.txt")
6. key in the path "d:\log\" in the "File Name:" box
7. Ctrl - v to paste the file name "aaa.txt" in to "File Name:" box, so the path name is "d:\log\aaa.txt" now
8. click OK

An array out of bounds exception occurs.
###@###.### 10/29/04 20:16 GMT

EVALUATION The problem is that when a file/dir. is already got selected by using mouse and then, if we key in fullpath of another file location in the JFileChooser's text field, then setSelectedFile is getting set to null from a call to clearSelection() of default list selection model. This is happening because of the wrong logic used for setSelectedFiles (File []) One way to avoid the problem is to deselect the selected file before keying the fullpath of another location. The other way is, always check the length of the array from getSelectedFiles() before using the returned file array. ###@###.### 2005-04-05 22:45:29 GMT Backporting 4949273. It seems to fix the problem and is a proven fix. ###@###.### 2005-04-20 20:50:29 GMT

WORK AROUND Make sure that no item (file/dir) is selected in the JFileChooser's list selection folder.(To deselect a selected item, use Ctrl+mouse click) ###@###.### 2005-04-05 22:19:26 GMT