Java Reference
In-Depth Information
Figure 16.7 The two tree applications
File: its/Trees/DirectoryTree.java
1.
package its.Trees;
2.
3.
import javax.swing.JTree;
4.
import javax.swing.tree.DefaultMutableTreeNode;
5.
import javax.swing.tree.DefaultTreeModel;
6.
import java.io.File;
7.
8.
public class DirectoryTree extends JTree {
9.
10.
private DefaultTreeModel directoryTreeModel;
11.
// The following path might have to be changed.
12.
private String startDir = "./its";
13.
private File startFile;
14.
15.
public DirectoryTree() {
startFile = new File(startDir);
16.
recursion(startFile);
17.
this .setModel(directoryTreeModel);
18.
}
19.
20.
21.
public DefaultMutableTreeNode recursion(File currentFile)
Search WWH ::




Custom Search