Author: Zafir Anjum
The UIManager holds a number of attributes that affects how a JTree is rendered. Changing these
attributes will affect all the JTree components created after this change. You can change the font, text
color and the default icons. To change these attributes you use the function
UIManager.put( keystring, valueobject );
Note that the second argument is an object. If you need to specify an integer then use the Integer class.
The list of attributes you can change are
| Tree.font | The font used to display the node that uses the default renderer |
| Tree.background | The background color of the tree |
| Tree.foreground | Foreground color - not used by the BasicTreeUI |
| Tree.hash | The color used to draw the lines connecting the nodes |
| Tree.textForeground | The text foreground color |
| Tree.textBackground | The text background color |
| Tree.selectionForeground | The text color for a selected node |
| Tree.selectionBackground | The text background for a selected node |
| Tree.selectionBorderColor | Color of the border for selected nodes |
| Tree.editorBorder | Border (the Border class) used when editing a node |
| Tree.leftChildIndent | Distance between left margin and where verical dashes will be
drawn |
| Tree.rightChildIndent | Distance to add to leftChildIndent to determine where cell
contents will be drawn. |
| Tree.rowHeight | Default height of a row |
| Tree.scrollsOnExpand | Boolean value that determines whether or not when a node is
expanded, as many of the descendants are scrolled to be inside the viewport as possible. The default is
true. |
| Tree.openIcon | Icon used for open folders |
| Tree.closedIcon | Icon used for closed folders |
| Tree.leafIcon | Icon used for leaf nodes |
| Tree.expandedIcon | Icon used to denote that the branch is expanded. On MS Windows this
is the minus sign |
| Tree.collapsedIcon | Icon used to denote that the branch is collapsed. On MS Windows this
is the plus sign |
| Tree.changeSelectionWithFocus | Boolean value that determines whether the selection is
changed with change in focus |
| Tree.drawsFocusBorderAroundIcon | Boolean value to indicate whether a border should be
drawn around the icons |
| | |
| Tree.iconBackground | Used on Motif |
| Tree.iconForeground | Used on Motif |
| Tree.iconHighlight | Used on Motif |
| Tree.iconShadow | Used on Motif |
| | |
| Tree.line | Linecolor - Used in metal L&F |
When you change any of the above attributes, only those components created after the change will use the
new values. All components already created before this change will not be affected. If you want to update
the earlier components as well then you can use the function SwingUtilities.updateComponentTreeUI(). Call
this function for each top level frame or for each JTree that had already been created before you changed
the global attributes.
Posted On: 21-Feb-1999