简体   繁体   中英

How to browse the files only with extensions .xls using JFileChooser in swing

I am trying to open a browse window using JFileChooser in java swing . By default its showing the all extension files when i browse the directory. But my requirement is

 JFileChooser should browse the files with specific extensions.

Try that:

JFileChooser fileChooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("XLS files", "xls");
fileChooser.setFileFilter(filter);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM