Most commonly, a tree component is paired with some other component. When the user selects tree nodes, some information shows up in another window. See Figure 6.33 for an example. When the user selects a class, the instance and static variables of that class are displayed in the text area to the right.
To obtain this behavior, you need to install a tree selection listener. The listener must implement the
TreeSelectionListener interface—an interface with a single method:
void valueChanged(TreeSelectionEvent event)
That method is called whenever the user selects or deselects tree nodes. ...