How to use a JTree component?
The example introduce you how to use the
JTree swing component to create a presentation of hierarchical data. The hierarchical data can be viewed in expand mode or collapse mode.
To create an item of the tree we create an instance of
DefaultMutableTreeNode which located in the
javax.swing.tree package. This class implements the
MutableTreeNode interfaces. Mutable means that the node can be changed. It can be added new children node or deleted children node from their parent node.
Below we create a tree component to display information about week day names and the month names. The
Root node have the
Days node contains a week day names and the
Months node contains the month names.