In your applications, you will often need to change the way a tree component draws the nodes. The most common change is, of course, to choose different icons for nodes and leaves. Other changes might involve changing the font of the node labels or drawing images at the nodes. All these changes are possible by installing a new tree cell renderer into the tree. By default, the
JTree class uses
DefaultTreeCellRenderer objects to draw each node. The
DefaultTreeCellRenderer class extends the
JLabel class. The label contains the node icon and the node label.
The cell renderer does not draw the “handles” for expanding and ...