views:

277

answers:

1

I need to embed JFilceChooser dialogbox in a Panel. I only need the file and folder view. How can i disable others panel that are included in dialogBox i.e(file operation, file selection and filter panel) from JFileChooser() dialogBox.. Thank you

+1  A: 

You might want to look into using a JTree to display the file structure.

It is fairly easy to convert a File structure into an implementation of a TreeModel.

Basically I would begin by making a class called FileTreeModel.

Then, you can use the top level directory as the root of the Model and go from there.

Then, all you need to do is set the TreeModel of a JTree to that of your FileTreeModel.

The code for the FileTreeModel may look something like this:

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

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

You will need to implement the rest of the interface. But it is fairly simple.

jjnguy