One aspect of the JTree that makes it more complex than other Swing classes is that the associated model in the model-delegate pattern for the JTree isn't where data is maintained. In JText Fields, the view (JText Area) offers a set Text(String) method, and its associated model (called a document) offers an insert String(int, String, Attribute Set).Both methods allow manipulation of the underlying data.Swing includes two very powerful but complex components called JTable and JTree.This article focuses solely on the JTree and explores various aspects of the JTree by using two examples that show how business objects can be visually represented within the JTree component.In a parent/child relationship, the child is analogous to a subclass of its parent.It inherits all the properties associated with its parent.
Node: Any position within the JTree where data associated with the business object is being represented. The collection of nodes will consist of a strict ancestry line.There are no more nodes connected to the leaf node.(Using the organizational chart example again, the leaf is the person that has no personnel reporting to him or her.) Root: A special kind of node.In the case of the JTree, neither the JTree class nor its associated model interface - the javax.Tree Model - offers a means of manipulating the underlying data.