com.sas.swing.visuals
Class TreeNodeIconCellRenderer

com.sas.swing.visuals.TreeNodeIconCellRenderer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.SwingConstants, javax.swing.tree.TreeCellRenderer

public class TreeNodeIconCellRenderer

A subclass of the javax.swing.tree.DefaultTreeCellRenderer. When creating the renderer component for each value, if the value is an instance of com.sas.swing.models.TreeNodeAdapter then the corresponding icon from teh TreeNodeAdapter will be used as the icon for the node. The icon can change whther the node is selected or not, or whether the icon is expanded or not. This renderer gives the user much more flexibility is setting icons on a JTree as they can be different for each node and can change on the fly.

See Also:
Serialized Form

Constructor Summary
TreeNodeIconCellRenderer()
          Returns a new default instance of TreeNodeIconCellRenderer.
 
Method Summary
 java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree, java.lang.Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
          Configures the renderer based on the passed in components.
 

Constructor Detail

TreeNodeIconCellRenderer

public TreeNodeIconCellRenderer()
Returns a new default instance of TreeNodeIconCellRenderer.

See Also:
DefaultTreeCellRenderer
Method Detail

getTreeCellRendererComponent

public java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree,
                                                       java.lang.Object value,
                                                       boolean sel,
                                                       boolean expanded,
                                                       boolean leaf,
                                                       int row,
                                                       boolean hasFocus)
Configures the renderer based on the passed in components. If the value is an instance of com.sas.swing.models.TreeNodeAdapter, then the appropriate icon is set from the TreeNodeAdapter. A TreeNodeAdapter is automatically setup everytime a com.sas.swing.models.TreeModelAdapter is set as the model on a JTree.

Specified by:
getTreeCellRendererComponent in interface javax.swing.tree.TreeCellRenderer
Overrides:
getTreeCellRendererComponent in class javax.swing.tree.DefaultTreeCellRenderer
Parameters:
tree - The tree the renderer is being used on, certain properties may be read from the tree like font and colors.
value - The specific value or node in the tree the renderer is going to render.
sel - Whether the node is selected in the tree
expanded - Whether the node is expanded in the tree
leaf - Whether the node is a leaf node or not
row - The row number the node exists on in the tree
hasFocus - Whether the node has focus in the tree or not
Returns:
The renderer for the specific value in the tree
See Also:
TreeModelAdapter, TreeNodeAdapter, DefaultTreeCellRenderer



Copyright © 2009 SAS Institute Inc. All Rights Reserved.