JDK-4218431 : JFileChooser does not support multi-file selection
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.2,1.1.6,1.2.0
  • Priority: P1
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris_2.5.1,solaris_2.6
  • CPU: generic,sparc
  • Submitted: 1999-03-09
  • Updated: 1999-07-15
  • Resolved: 1999-07-15
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
1.3.0 betaFixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
I'm using JDK 1.2 so I think that implies I'm also using Swing 1.2.

The setMultiSelectionEnabled() method on JFileChooser is documented as
not being implemented yet.  Therefore, the call getSelectedFiles() will
never return anything.  Not being implemented is the bug.  Providing API
calls and not implementing them makes the lack of implementation a bug
(not an RFE as bugid 4102455 suggests).

<FLAME>
It is still difficult to write an acceptable file-oriented application
in Java.  In JDK 1.1, the file chooser gave us unimplemented calls for
setting filters, making it impossible to narrow the choice of files for
the user.  JDK 1.1 also did not provide a directory chooser or provide
multiple selection.  Swing has made progress and now provides filters
and directory choosing, but still no way to select multiple files.
Another notable omission for file-oriented applications is a print dialog.
These are requirements if the goal is for the Java platform to compete
with Windows.
</FLAME>

Java WorkShop 3.0 Community Edition was recently made available via
web downloads.  Once of the first comments we received, was this one
which relates to this bug and 4218429.

From: Fred Romelfanger <###@###.###>
Subject: When adding files to the project, you should be ab
To: ###@###.###

User Name:  Fred Romelfanger
Email:      ###@###.###
Platform:   SunOS
Version: Java WorkShop 3.0 Community Edition build_19 Mar  3 1999
Java Version: 1.2

When adding files to the project, you should be able to select multiple files or
select a specific directory to include.  The file selection screen would allow me
to select multiple files, but would only add one at a time to the files for the
project.  Also when creating a new project the pull down for file type should
have an option to just specify java sources rather than all files.


Name: krT82822			Date: 05/30/99


For a long time now,  the documentation for javax.swing.JFileChooser 
says 'this feature has not yet been implemented in the current L&Fs' 
for the multiple file selection.

Please don't forget to implement it, it would be very useful!

BTW, a separate dialog for direction selection would be nice: I know JFileChooser has 
a directories-only option, but users say it's a bit confusing when used
for this purpose.
(Review ID: 54339)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: kestrel-beta INTEGRATED IN: kestrel-beta
14-06-2004

EVALUATION I agree with the <FLAME> tag. HERE is an ugly solution, but it's better than waiting for a fix from the Swing team ;-): (from http://manning.spindoczine.com/sbe/files/uts2/Chapter14html/Chapter14.htm) public static File[] getSelectedFiles(JFileChooser chooser) { // Although JFileChooser won't give us this information, // we need it... Container c1 = (Container)chooser.getComponent(3); JList list = null; while (c1 != null) { Container c = (Container)c1.getComponent(0); if (c instanceof JList) { list = (JList)c; break; } c1 = c; } Object[] entries = list.getSelectedValues(); File[] files = new File[entries.length]; for (int k=0; k<entries.length; k++) { if (entries[k] instanceof File) files[k] = (File)entries[k]; } return files; } Ludovic
11-06-2004

WORK AROUND I agree with the <FLAME> tag. HERE is an ugly solution, but it's better than waiting for a fix from the Swing team ;-): (from http://manning.spindoczine.com/sbe/files/uts2/Chapter14html/Chapter14.htm) public static File[] getSelectedFiles(JFileChooser chooser) { // Although JFileChooser won't give us this information, // we need it... Container c1 = (Container)chooser.getComponent(3); JList list = null; while (c1 != null) { Container c = (Container)c1.getComponent(0); if (c instanceof JList) { list = (JList)c; break; } c1 = c; } Object[] entries = list.getSelectedValues(); File[] files = new File[entries.length]; for (int k=0; k<entries.length; k++) { if (entries[k] instanceof File) files[k] = (File)entries[k]; } return files; } ludovic.champenois@Eng 1999-04-15
15-04-1999

SUGGESTED FIX Implement the API calls that are provided. I fail to understand the logic behind providing unimplemented calls. I agree with the <FLAME> tag. HERE is an ugly solution, but it's better than waiting for a fix from the Swing team ;-): (from http://manning.spindoczine.com/sbe/files/uts2/Chapter14html/Chapter14.htm) public static File[] getSelectedFiles(JFileChooser chooser) { // Although JFileChooser won't give us this information, // we need it... Container c1 = (Container)chooser.getComponent(3); JList list = null; while (c1 != null) { Container c = (Container)c1.getComponent(0); if (c instanceof JList) { list = (JList)c; break; } c1 = c; } Object[] entries = list.getSelectedValues(); File[] files = new File[entries.length]; for (int k=0; k<entries.length; k++) { if (entries[k] instanceof File) files[k] = (File)entries[k]; } return files; } ludovic.champenois@Eng 1999-04-15
15-04-1999