1

我需要将对话框嵌入JFileChooserPanel. 我只需要文件和文件夹视图。如何从..禁用dialogBoxie(文件操作、文件选择和过滤器面板)中包含的其他面板JFileChooser() dialogBox

谢谢

4

1 回答 1

2

您可能想研究使用 aJTree来显示文件结构。

将 File 结构转换为TreeModel.

基本上我会先创建一个名为FileTreeModel.

然后,您可以使用顶层目录作为模型的根目录并从那里开始。

然后,您需要做的就是将TreeModela 的设置JTree为您的FileTreeModel.

的代码FileTreeModel可能如下所示:

private File root;
public TreeModel(File root){
    this.root = root;
}

public boolean isLeaf(Object node){
    File f = (File) node;
    return !f.isDirectory();
}

您将需要实现接口的其余部分。但这相当简单。

于 2009-04-28T09:18:55.927 回答