In our first example program, we will simply display a tree with a few nodes (see Figure 6.18 on p. 424). As with many other Swing components, you need to provide a model of the data, and the component displays it for you. To construct a
JTree, supply the tree model in the constructor:
TreeModel model = . . .; JTree tree = new JTree(model);
There are also constructors that construct trees out of a collection of elements:
JTree(Object nodes) JTree(Vector<?> nodes) JTree(Hashtable<?, ?> nodes) // the values become the nodes
These constructors are not very useful. They merely build a forest ...