Every computer user who has worked with a hierarchical file system has seen tree displays. Of course, directories and files form only one of the many examples of tree-like organizations. Many tree structures arise in everyday life, such as the hierarchy of countries, states, and cities shown in Figure 6.15.
As programmers, we often need to display tree structures. Fortunately, the Swing library has a
JTree class for this purpose. The
JTree class (together with its helper classes) takes care of laying out the tree and processing user requests for expanding and collapsing nodes. In this section, you will learn how to put the
JTree class to use.
As with the other complex Swing ...