java JFileChooser 选择一个多文件java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16236011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 22:19:58 来源:igfitidea点击:
JFileChooser to select a multiple file java
提问by Renish Khunt
That is my code to the JFileChooser to select a file now i want to select multiple file what to do
那是我给 JFileChooser 选择文件的代码,现在我想选择多个文件要做什么
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();
}
how to select a multiple file using JFileChooser Please Help...
如何使用 JFileChooser 选择多个文件 请帮助...
回答by afk5min
chose.setMultiSelectionEnabled(true)
chose.setMultiSelectionEnabled(true)
回答by Alya'a Gamal
Try this:
试试这个:
JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
chooser.showOpenDialog(frame);
File[] files = chooser.getSelectedFiles();