United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6186865 : JFileChooser does not take full pathname

Details
Type:
Bug
Submit Date:
2004-10-29
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2005-05-28
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.2_06
Fixed Versions:
1.4.2_09 (b02)

Related Reports
Relates:

Sub Tasks

Description
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.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
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

                                    

Comments
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
                                     
2005-04-05
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
                                     
2005-04-05



Hardware and Software, Engineered to Work Together