I have a question about the JFileChooser in Swing. I'm trying to get multiple file extensions in the drop-down box, but have no idea how to do it.
There is the method
extFilter = FileNameExtensionFilter(description, extensions);
that I can then use by writing
fileChooser.setFileFilter(extFilter);
however, as you can see, this only supports one option in the drop-down list. How do I add more?
use
filter.addChoosableFileFilter(new FileNameExtensionFilter(description, extensions));
as many as the number of your extensions.
I know this question was asked long back, but one can take the following steps to define multiple extensions:
JFileChooser jfc = new JFileChooser(); jfc.setFileFilter(new FileNameExtensionFilter("Select XSL Files","xsl","xslt"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With