|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnextapp.echo2.app.Component
nextapp.echo2.app.Label
echopointng.tree.DefaultTreeCellRenderer
public class DefaultTreeCellRenderer
Used to display an entry in a tree. If the tree cell value is a DefaultMutableTreeNode and its user object is a Component then the DefaultTreeCellRenderer will return null on getTreeCellRenderText and return the Component in getTreeCellRendererComponent.
Otherwise it will "cast" the cell value to a String via toString() and return a LabelEx via the getTreeCellRenderText method. It uses the Tree's TreeIcon object to obtain an icon for "parent" and "leaf" nodes.
You can derived your own TreeCellRendererclass from this one and
specify your own icons for each node if you wish.
Note that this class also has Style support so you can set appearance attributes via a Style object or the EchoPoint CSS support.
The standard LabelEx background, foreground and font properties are used for non selected tree cell nodes. The selectedBackground, selectedForeground and selectedFont properties are used for selected tree cell nodes.
| Field Summary | |
|---|---|
static Font |
DEFAULT_FONT
The default Tree Cell Font |
static Color |
DEFAULT_SELECTED_BACKGROUND
The default Selected Tree Cell Background |
static Font |
DEFAULT_SELECTED_FONT
The default Selected Tree Cell Font |
static Color |
DEFAULT_SELECTED_FOREGROUND
The default Selected Tree Cell FOREGROUND |
static java.lang.String |
PROPERTY_SELECTED_BACKGROUND
|
static java.lang.String |
PROPERTY_SELECTED_FONT
|
static java.lang.String |
PROPERTY_SELECTED_FOREGROUND
|
| Fields inherited from class nextapp.echo2.app.Label |
|---|
PROPERTY_ICON, PROPERTY_ICON_TEXT_MARGIN, PROPERTY_LINE_WRAP, PROPERTY_TEXT, PROPERTY_TEXT_ALIGNMENT, PROPERTY_TEXT_POSITION, PROPERTY_TOOL_TIP_TEXT |
| Constructor Summary | |
|---|---|
DefaultTreeCellRenderer()
Creates a new instance of DefaultTreeCellRenderer. |
|
| Method Summary | |
|---|---|
Color |
getSelectedBackground()
|
Font |
getSelectedFont()
|
Color |
getSelectedForeground()
|
Component |
getTreeCellRendererComponent(Tree tree,
java.lang.Object node,
boolean selected,
boolean expanded,
boolean leaf)
If the value is a Component then it will be returned as is, otherwise it returns null. |
Label |
getTreeCellRendererText(Tree tree,
java.lang.Object node,
boolean sel,
boolean expanded,
boolean leaf)
Configures the renderer based on the passed in parameters. |
void |
setBackground(Color newValue)
Sets the default background color of the Component. |
void |
setFont(Font newValue)
Sets the default text font of the Component. |
void |
setForeground(Color newValue)
Sets the default foreground color of the Component. |
void |
setSelectedBackground(Color newValue)
Sets the background color to be used for selected tree cell nodes. |
void |
setSelectedFont(Font newValue)
Sets the font to be used for selected tree cell nodes. |
void |
setSelectedForeground(Color newValue)
Sets the foreground color to be used for selected tree cell nodes. |
| Methods inherited from class nextapp.echo2.app.Label |
|---|
getIcon, getIconTextMargin, getText, getTextAlignment, getTextPosition, getToolTipText, isLineWrap, isValidChild, setIcon, setIconTextMargin, setLineWrap, setText, setTextAlignment, setTextPosition, setToolTipText |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Font DEFAULT_FONT
public static final Color DEFAULT_SELECTED_BACKGROUND
public static final Color DEFAULT_SELECTED_FOREGROUND
public static final Font DEFAULT_SELECTED_FONT
public static final java.lang.String PROPERTY_SELECTED_BACKGROUND
public static final java.lang.String PROPERTY_SELECTED_FOREGROUND
public static final java.lang.String PROPERTY_SELECTED_FONT
| Constructor Detail |
|---|
public DefaultTreeCellRenderer()
| Method Detail |
|---|
public Color getSelectedBackground()
public Color getSelectedForeground()
public Font getSelectedFont()
public void setSelectedBackground(Color newValue)
newValue - - The newValue to set.public void setSelectedForeground(Color newValue)
newValue - - The newValue to set.public void setSelectedFont(Font newValue)
newValue - - The newValue to set.public void setBackground(Color newValue)
ComponentComponent.
setBackground in class ComponentnewValue - the new background ColorComponent.setBackground(nextapp.echo2.app.Color)public void setForeground(Color newValue)
ComponentComponent.
setForeground in class ComponentnewValue - the new foreground ColorComponent.setForeground(nextapp.echo2.app.Color)public void setFont(Font newValue)
ComponentComponent.
setFont in class ComponentnewValue - the new FontComponent.setFont(nextapp.echo2.app.Font)
public Component getTreeCellRendererComponent(Tree tree,
java.lang.Object node,
boolean selected,
boolean expanded,
boolean leaf)
getTreeCellRendererComponent in interface TreeCellRendererTreeCellRenderer.getTreeCellRendererComponent(Tree, Object, boolean, boolean, boolean)
public Label getTreeCellRendererText(Tree tree,
java.lang.Object node,
boolean sel,
boolean expanded,
boolean leaf)
The foreground color of the LabelEx is set based on the selection while
the icon is set based on on leaf and expanded.
The same LabelEx object is returned for each call to this method. The Tree rendering code uses only the public properties of the return LabelEx. In fact since DefaultTreeCellRenderer is derived from LabelEx it simply returns itself.
getTreeCellRendererText in interface TreeCellRendererTreeCellRenderer.getTreeCellRendererText(Tree, Object, boolean, boolean, boolean)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||