javax.swing.tree

Class DefaultTreeCellRenderer

Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable, SwingConstants, TreeCellRenderer

public class DefaultTreeCellRenderer
extends JLabel
implements TreeCellRenderer

A default implementation of the TreeCellRenderer interface.
See Also:
Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class javax.swing.JLabel

JLabel.AccessibleJLabel

Nested classes/interfaces inherited from class javax.swing.JComponent

JComponent.AccessibleJComponent

Nested classes/interfaces inherited from class java.awt.Container

Container.AccessibleAWTContainer

Nested classes/interfaces inherited from class java.awt.Component

Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy

Field Summary

protected Color
backgroundNonSelectionColor
The background color for non-selected cells.
protected Color
backgroundSelectionColor
The background color for selected cells.
protected Color
borderSelectionColor
The border color for selected tree cells.
protected Icon
closedIcon
The icon used to represent non-leaf nodes that are closed.
protected boolean
hasFocus
A flag indicating the current focus status.
protected Icon
leafIcon
The icon used to represent leaf nodes.
protected Icon
openIcon
The icon used to represent non-leaf nodes that are open.
protected boolean
selected
A flag indicating the current selection status.
protected Color
textNonSelectionColor
The color used for text in non-selected cells.
protected Color
textSelectionColor
The color used for text in selected cells.

Fields inherited from class javax.swing.JLabel

labelFor

Fields inherited from class javax.swing.JComponent

TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, accessibleContext, listenerList, ui

Fields inherited from class java.awt.Component

BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT

Fields inherited from interface java.awt.image.ImageObserver

ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH

Fields inherited from interface javax.swing.SwingConstants

BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST

Constructor Summary

DefaultTreeCellRenderer()
Creates a new tree cell renderer with defaults appropriate for the current LookAndFeel.

Method Summary

void
firePropertyChange(String name, boolean oldValue, boolean newValue)
For performance reasons, this method is overridden to do nothing.
void
firePropertyChange(String name, byte oldValue, byte newValue)
For performance reasons, this method is overridden to do nothing.
void
firePropertyChange(String name, char oldValue, char newValue)
For performance reasons, this method is overridden to do nothing.
void
firePropertyChange(String name, double oldValue, double newValue)
For performance reasons, this method is overridden to do nothing.
void
firePropertyChange(String name, float oldValue, float newValue)
For performance reasons, this method is overridden to do nothing.
void
firePropertyChange(String name, int oldValue, int newValue)
For performance reasons, this method is overridden to do nothing.
protected void
firePropertyChange(String name, Object oldValue, Object newValue)
For performance reasons, this method is overridden to do nothing.
void
firePropertyChange(String name, long oldValue, long newValue)
For performance reasons, this method is overridden to do nothing.
void
firePropertyChange(String name, short oldValue, short newValue)
For performance reasons, this method is overridden to do nothing.
Color
getBackgroundNonSelectionColor()
Returns the background color for tree cells that are not selected.
Color
getBackgroundSelectionColor()
Returns the background color for tree cells that are selected.
Color
getBorderSelectionColor()
Returns the border color for tree cells that are selected.
Icon
getClosedIcon()
Returns the icon displayed for non-leaf nodes that are closed.
Icon
getDefaultClosedIcon()
Returns the default icon for non-leaf tree cells that are closed (not expanded).
Icon
getDefaultLeafIcon()
Returns the default icon for leaf tree cells.
Icon
getDefaultOpenIcon()
Returns the default icon for non-leaf tree cells that are open (expanded).
Font
getFont()
Returns the current font.
Icon
getLeafIcon()
Returns the icon displayed for leaf nodes.
Icon
getOpenIcon()
Returns the icon displayed for non-leaf nodes that are open (expanded).
Dimension
getPreferredSize()
Returns the preferred size of the cell.
Color
getTextNonSelectionColor()
Returns the text color for tree cells that are not selected.
Color
getTextSelectionColor()
Returns the text color for tree cells that are selected.
Component
getTreeCellRendererComponent(JTree tree, Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
Returns a component (in fact this) that can be used to render a tree cell with the specified state.
void
paint(Graphics g)
Paints the value.
void
repaint(Rectangle area)
For performance reasons, this method is overridden to do nothing.
void
repaint(long tm, int x, int y, int width, int height)
For performance reasons, this method is overridden to do nothing.
void
revalidate()
For performance reasons, this method is overridden to do nothing.
void
setBackground(Color c)
Sets the background color.
void
setBackgroundNonSelectionColor(Color c)
Sets the background color for tree cells that are not selected.
void
setBackgroundSelectionColor(Color c)
Sets the background color for tree cells that are selected.
void
setBorderSelectionColor(Color c)
Sets the border color for tree cells that are selected.
void
setClosedIcon(Icon icon)
Sets the icon to be displayed for non-leaf nodes that are closed.
void
setFont(Font f)
Sets the font.
void
setLeafIcon(Icon icon)
Sets the icon to be displayed for leaf nodes.
void
setOpenIcon(Icon icon)
Sets the icon to be displayed for non-leaf nodes that are open (expanded).
void
setTextNonSelectionColor(Color c)
Sets the text color for tree cells that are not selected.
void
setTextSelectionColor(Color c)
Sets the text color for tree cells that are selected.
void
validate()
For performance reasons, this method is overridden to do nothing.

Methods inherited from class javax.swing.JLabel

checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setFont, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI

Methods inherited from class javax.swing.JComponent

addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI

Methods inherited from class java.awt.Container

add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, extends EventListener> T[] getListeners, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponentZOrder, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree

Methods inherited from class java.awt.Component

action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

backgroundNonSelectionColor

protected Color backgroundNonSelectionColor
The background color for non-selected cells.

backgroundSelectionColor

protected Color backgroundSelectionColor
The background color for selected cells.

borderSelectionColor

protected Color borderSelectionColor
The border color for selected tree cells.

closedIcon

protected Icon closedIcon
The icon used to represent non-leaf nodes that are closed.

hasFocus

protected boolean hasFocus
A flag indicating the current focus status.

leafIcon

protected Icon leafIcon
The icon used to represent leaf nodes.

openIcon

protected Icon openIcon
The icon used to represent non-leaf nodes that are open.

selected

protected boolean selected
A flag indicating the current selection status.

textNonSelectionColor

protected Color textNonSelectionColor
The color used for text in non-selected cells.

textSelectionColor

protected Color textSelectionColor
The color used for text in selected cells.

Constructor Details

DefaultTreeCellRenderer

public DefaultTreeCellRenderer()
Creates a new tree cell renderer with defaults appropriate for the current LookAndFeel.

Method Details

firePropertyChange

public void firePropertyChange(String name,
                               boolean oldValue,
                               boolean newValue)
For performance reasons, this method is overridden to do nothing.
Overrides:
firePropertyChange in interface JComponent
Parameters:
name - the property name.
oldValue - the old value.
newValue - the new value.

firePropertyChange

public void firePropertyChange(String name,
                               byte oldValue,
                               byte newValue)
For performance reasons, this method is overridden to do nothing.
Overrides:
firePropertyChange in interface Component
Parameters:
name - the property name.
oldValue - the old value.
newValue - the new value.

firePropertyChange

public void firePropertyChange(String name,
                               char oldValue,
                               char newValue)
For performance reasons, this method is overridden to do nothing.
Overrides:
firePropertyChange in interface Component
Parameters:
name - the property name.
oldValue - the old value.
newValue - the new value.

firePropertyChange

public void firePropertyChange(String name,
                               double oldValue,
                               double newValue)
For performance reasons, this method is overridden to do nothing.
Overrides:
firePropertyChange in interface Component
Parameters:
name - the property name.
oldValue - the old value.
newValue - the new value.

firePropertyChange

public void firePropertyChange(String name,
                               float oldValue,
                               float newValue)
For performance reasons, this method is overridden to do nothing.
Overrides:
firePropertyChange in interface Component
Parameters:
name - the property name.
oldValue - the old value.
newValue - the new value.

firePropertyChange

public void firePropertyChange(String name,
                               int oldValue,
                               int newValue)
For performance reasons, this method is overridden to do nothing.
Overrides:
firePropertyChange in interface JComponent
Parameters:
name - the property name.
oldValue - the old value.
newValue - the new value.

firePropertyChange

protected void firePropertyChange(String name,
                                  Object oldValue,
                                  Object newValue)
For performance reasons, this method is overridden to do nothing.
Overrides:
firePropertyChange in interface Component
Parameters:
name - the property name.
oldValue - the old value.
newValue - the new value.

firePropertyChange

public void firePropertyChange(String name,
                               long oldValue,
                               long newValue)
For performance reasons, this method is overridden to do nothing.
Overrides:
firePropertyChange in interface Component
Parameters:
name - the property name.
oldValue - the old value.
newValue - the new value.

firePropertyChange

public void firePropertyChange(String name,
                               short oldValue,
                               short newValue)
For performance reasons, this method is overridden to do nothing.
Overrides:
firePropertyChange in interface Component
Parameters:
name - the property name.
oldValue - the old value.
newValue - the new value.

getBackgroundNonSelectionColor

public Color getBackgroundNonSelectionColor()
Returns the background color for tree cells that are not selected. The default value is obtained from the LookAndFeel defaults table using the key Tree.textBackground.
Returns:
The background color for tree cells that are not selected.

getBackgroundSelectionColor

public Color getBackgroundSelectionColor()
Returns the background