How to select multiple folders and files in Javafx

2020-07-13 11:26发布

问题:

I am working on javafx 2. but there is no feature of multiple folders and files available on the filechooser.

There is the Directory chooser but it selects only one folder. How can i solve this problem. Please give me any suggestion?

回答1:

We can use JFileChooer of Swing component. But then its give error like Headless something. So remove this error by following steps.

1) Initialised all component of swing before javafx. 2) use System.setProperty and set Headless false .

Then jfilechooser works. Thanks to all.



回答2:

JavaFX supports single and multiple file dialogs:

http://docs.oracle.com/javafx/2/api/javafx/stage/FileChooser.html

and single directory dialog:

http://docs.oracle.com/javafx/2/api/javafx/stage/DirectoryChooser.html

There was a special RFE for this : https://bugs.openjdk.java.net/browse/JDK-8101526.

There is a special RFE for multiple directories chosign, you can wait, until it will be fixed : https://bugs.openjdk.java.net/browse/JDK-8091403, also, you can vote it up, for it to be fixed with higher priority