JFileChooser,以选择多个文件的Java
问题描述:
这是我的代码JFileChooser,以选择一个文件,现在我想选择多个文件做JFileChooser,以选择多个文件的Java
JFileChooser chose=new JFileChooser();
chose.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int r=chose.showOpenDialog(new JFrame());
if(r == chose.APPROVE_OPTION){
String filepath= chose.getSelectedFile().getAbsolutePath();
}
如何选择使用的JFileChooser请帮助多个文件的.. 。
答
chose.setMultiSelectionEnabled(true)
+0
感谢您的快速回放 – 2013-04-26 12:13:19
答
试试这个:
JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
chooser.showOpenDialog(frame);
File[] files = chooser.getSelectedFiles();
+0
感谢您的快速回放 – 2013-04-26 12:13:45
有至少两个duplicat这个问题,请在询问之前尝试Googleing! http://stackoverflow.com/questions/11922152/jfilechooser-to-open-multiple-txt-files http://stackoverflow.com/questions/13060371/adding-multiple-files-with-jfilechooser – jazzbassrob 2013-04-26 12:06:51