gpt4 book ai didi

java - 使用 FileDialog 选择多个文件不起作用

转载 作者:行者123 更新时间:2023-11-30 05:42:15 25 4
gpt4 key购买 nike

当窗口对话框打开时,我无法选择多个文件。

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);
}
}

我希望能够在对话框窗口中选择一个或多个文件,但无法使用 SHIFTCTRL 进行多项选择

控制台输出:

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、NSRemoteViewNSOpenPanel 的错误,还是我的代码中遗漏了某些内容?

最佳答案

要启用多选,您只需更改文件对话框的调用顺序

来自:

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);

关于java - 使用 FileDialog 选择多个文件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55438212/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com