JavaFX allows selecting a file via FileChooser and selecting a directory via DirectoryChooser, but how do I allow it to select both at once?
Something like Swing's JFileChooser.FILES_AND_DIRECTORIES option.
Currently I'm just using JFileChooser directly, but it's not exactly a good visual match:
JFileChooser chooser = new JFileChooser(".");
chooser.setMultiSelectionEnabled(true);
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
int ret = chooser.showOpenDialog(null);
if(ret == JFileChooser.APPROVE_OPTION) {
File[] files = chooser.getSelectedFiles();
...
}
There is no such functionality in JavaFX 2.2 or current JavaFX 8 builds.
A FILES_AND_DIRECTORIES chooser for JavaFX was requested in RT-22621.
The request was declined as Won't Fix for the following reason:
For Java 8, Windows XP is no longer supported and perhaps Linux will be enhanced to natively provide such functionality so that JavaFX could use it and such a feature could be provided in JavaFX in the future. You may comment on the linked Jira case to register your interest.