我需要知道如何在 java 中获取“浏览文件夹”对话框。我知道 SWT。但是我需要在摇摆中做吗?有什么解决办法吗?
[当我们开始 Eclipse 时,它会要求选择工作区。我们当时可以看到浏览文件夹对话框]提前致谢。
我需要知道如何在 java 中获取“浏览文件夹”对话框。我知道 SWT。但是我需要在摇摆中做吗?有什么解决办法吗?
[当我们开始 Eclipse 时,它会要求选择工作区。我们当时可以看到浏览文件夹对话框]提前致谢。
如果添加以下命令,您可以强制 JFileChooser 仅选择文件夹。
_fileChooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY);
在 Bibhaw 发布的片段中。
JFileChooser j = new JFileChooser();
j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
Integer opt = j.showSaveDialog(this);
预先咀嚼的代码:
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new java.io.File(".")); // start at application current directory
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = fc.showSaveDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
File yourFolder = fc.getSelectedFile();
}
使用 JFIleChooser。例如
JFileChooser chooser = new JFileChooser("C:\example");
详情请通过:
http://leepoint.net/notes-java/GUI/containers/20dialogs/30filechooser.html
http://download.oracle.com/javase/tutorial/uiswing/components/filechooser.html