JDK-7125172 : FileDialog objects don't allow directory AND files selection simultaneously
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • CPU: x86
  • Submitted: 2011-12-27
  • Updated: 2021-07-13
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
tbdUnresolved
Related Reports
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
The native file chooser only allows file selection making it useless for apps that need to import many files at once (or even just a directory).

I don't know the history of the limitation; though it must exist, since it's unnatural, but i request that it be reviewed: all platforms java supports allow the native file choser to select directories (and both directories and files at the same time).

JUSTIFICATION :
Because JFileChooser is broken in contrast with the native file choosers. Because it is much slower. Because it slows down classloading for the whole application. And because most of it's functions could be done by a FileDialog that accepted both files and directories, with maybe a filefilter optional.


CUSTOMER SUBMITTED WORKAROUND :
Use one of the many, many buggy, non portable jni libraries that expose or attempt recreate the moving target that is the native filechooser in pure swing
eg:
http://code.google.com/p/gtkjfilechooser/ (currently broken in java7)
http://code.google.com/p/xfiledialog/ (windows only, jni, ironic since i suspect the original motivation for the limitation was inadequate windows API)

Comments
EVALUATION Note: 6927978 already covers the directory chooser dialog. This CR covers the mode that would allow selecting both files and folders at the same time. On MS Windows the folder browser allows one to choose both files and directories [1]. It may make sense to add this option to the DirectoryDialog (6927978) since it's going to use the same native widget on Windows. Other platforms seem to use the same native widget in any mode. [1] http://mail.openjdk.java.net/pipermail/awt-dev/2011-December/002127.html
30-12-2011