public class FileTreeModel extends Object implements TreeModel
Tree fileTree = new Tree(new FileTreeModel(true)) {
protected String childToDisplayLabel(Object child) {
if (((String) child).endsWith("/")) {
return ((String) child).substring(((String) child).lastIndexOf('/', ((String) child).length() - 2));
}
return ((String) child).substring(((String) child).lastIndexOf('/'));
}
};
Constructor and Description |
---|
FileTreeModel(boolean showFiles)
Construct a filesystem tree model
|
Modifier and Type | Method and Description |
---|---|
void |
addExtensionFilter(String extension)
Shows only files with the given extension
|
Vector |
getChildren(Object parent)
Returns the child objects representing the given parent, null should return
the root objects
|
boolean |
isLeaf(Object node)
Is the node a leaf or a folder
|
public FileTreeModel(boolean showFiles)
showFiles
- indicates whether this is a directory only view or a whole filesystem viewpublic void addExtensionFilter(String extension)
extension
- the file extension to displaypublic Vector getChildren(Object parent)
getChildren
in interface TreeModel
parent
- the parent object whose children should be returned, null would return the
tree roots