打开窗口对话框时,我不能选择多个文件。
void setup() {
size(100,100);
select_multi_files_via_FileDialog();
}
import java.awt.FileDialog;
import java.awt.Frame;
File [] select_multi_files;
void select_multi_files_via_FileDialog() {
Frame frame = null;
FileDialog dialog = new FileDialog(frame, "select file", FileDialog.LOAD);
dialog.setVisible(true);
dialog.setMultipleMode(true);
String directory = dialog.getDirectory();
println("multifile is",dialog.isMultipleMode());
select_multi_files = dialog.getFiles();
if(select_multi_files != null && select_multi_files.length > 0) {
printArray(select_multi_files);
}
}
我希望能够在对话框窗口中选择一个或多个文件,但是无法使用SHIFT
或CTRL
进行多选
控制台输出:
2019-03-31 07:29:28.173 java[1808:250416] warning: <NSRemoteView: 0x7fc2801911b0> determined it was necessary to configure <NSOpenPanel: 0x7fc2798f75e0> to support remote view vibrancy
multifile is true
[0] /Users/stan/En_cours/BOULOT/MEDIA/MEDIA ROMANESCO/FILM/extrait_film/alien_1_9e_pasager_ripley_extrait.mov
我不知道这是OSX-Mojave,Java,NSRemoteView
,NSOpenPanel
还是我的代码中遗漏了什么错误?
答案 0 :(得分:1)
要启用多选,您只需更改文件对话框的调用顺序
发件人:
FileDialog dialog = new FileDialog(frame, "select file", FileDialog.LOAD);
dialog.setVisible(true);
dialog.setMultipleMode(true);
收件人:
FileDialog dialog = new FileDialog(frame, "select file", FileDialog.LOAD);
dialog.setMultipleMode(true);
dialog.setVisible(true);