Link to home
Start Free TrialLog in
Avatar of pofpof98
pofpof98

asked on

How to force an extension, for example *.xml, using a JFileChooser object

Hello

I'd like to have an example which show force an extension by default in the TextArea File name and Using the JFileChooser object.

I have created an object like this : JFileChooser jfc = new JFileChooser();
But i didn't find a method which enable me to force an extension, for example *.xml.

Thanks
Regards

AC
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Use a FileFilter
ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> JFileChooser fileChooser = new JFileChooser(new File(filename));  // to have a default selected file
but can of course simply be: JFileChooser fileChooser = new JFileChooser();
Thanks for accepting