java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
javax.swing.tree.DefaultTreeCellRenderer
TreeCellRenderer
interface.
protected Color
backgroundNonSelectionColor
protected Color
backgroundSelectionColor
protected Color
borderSelectionColor
protected Icon
closedIcon
protected boolean
hasFocus
protected boolean
selected
protected Color
textNonSelectionColor
protected Color
textSelectionColor
BOTTOM
, CENTER
, EAST
, HORIZONTAL
, LEADING
, LEFT
, NEXT
, NORTH
, NORTH_EAST
, NORTH_WEST
, PREVIOUS
, RIGHT
, SOUTH
, SOUTH_EAST
, SOUTH_WEST
, TOP
, TRAILING
, VERTICAL
, WEST
DefaultTreeCellRenderer()
LookAndFeel
.
void
firePropertyChange(String name, boolean oldValue, boolean newValue)
void
firePropertyChange(String name, byte oldValue, byte newValue)
void
firePropertyChange(String name, char oldValue, char newValue)
void
firePropertyChange(String name, double oldValue, double newValue)
void
firePropertyChange(String name, float oldValue, float newValue)
void
firePropertyChange(String name, int oldValue, int newValue)
protected void
firePropertyChange(String name, Object oldValue, Object newValue)
void
firePropertyChange(String name, long oldValue, long newValue)
void
firePropertyChange(String name, short oldValue, short newValue)
Color
getBackgroundNonSelectionColor()
Color
getBackgroundSelectionColor()
Color
getBorderSelectionColor()
Icon
getClosedIcon()
Icon
getDefaultClosedIcon()
Icon
getDefaultLeafIcon()
Icon
getDefaultOpenIcon()
Icon
getLeafIcon()
Icon
getOpenIcon()
Dimension
getPreferredSize()
Color
getTextNonSelectionColor()
Color
getTextSelectionColor()
Component
getTreeCellRendererComponent(JTree tree, Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
this
) that can be used to
render a tree cell with the specified state.
void
repaint(long tm, int x, int y, int width, int height)
void
revalidate()
void
setBackground(Color c)
void
setBackgroundNonSelectionColor(Color c)
void
setBackgroundSelectionColor(Color c)
void
setBorderSelectionColor(Color c)
void
setClosedIcon(Icon icon)
void
setLeafIcon(Icon icon)
void
setOpenIcon(Icon icon)
void
setTextNonSelectionColor(Color c)
void
setTextSelectionColor(Color c)
void
validate()
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
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
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
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
protected Color backgroundNonSelectionColor
The background color for non-selected cells.
protected Color backgroundSelectionColor
The background color for selected cells.
- See Also:
setBackgroundSelectionColor(Color)
protected Color borderSelectionColor
The border color for selected tree cells.
- See Also:
setBorderSelectionColor(Color)
protected Icon closedIcon
The icon used to represent non-leaf nodes that are closed.
- See Also:
setClosedIcon(Icon)
protected Icon openIcon
The icon used to represent non-leaf nodes that are open.
- See Also:
setOpenIcon(Icon)
protected Color textNonSelectionColor
The color used for text in non-selected cells.
- See Also:
setTextNonSelectionColor(Color)
protected Color textSelectionColor
The color used for text in selected cells.
- See Also:
setTextSelectionColor(Color)
public DefaultTreeCellRenderer()
Creates a new tree cell renderer with defaults appropriate for the currentLookAndFeel
.
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.
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.
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.
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.
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.
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.
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.
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.
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.
public Color getBackgroundNonSelectionColor()
Returns the background color for tree cells that are not selected. The default value is obtained from theLookAndFeel
defaults table using the keyTree.textBackground
.
- Returns:
- The background color for tree cells that are not selected.
public Color getBackgroundSelectionColor()
Returns the background color for tree cells that are selected. The default value is obtained from theLookAndFeel
defaults table using the keyTree.selectionBackground
.
- Returns:
- The background color for tree cells that are selected.
- See Also:
setBackgroundSelectionColor(Color)
public Color getBorderSelectionColor()
Returns the border color for tree cells that are selected. The default value is obtained from theLookAndFeel
defaults table using the keyTree.selectionBorderColor
.
- Returns:
- The border color for tree cells that are selected.
- See Also:
setBorderSelectionColor(Color)
public Icon getClosedIcon()
Returns the icon displayed for non-leaf nodes that are closed. The default value is initialised from theLookAndFeel
.
- Returns:
- The closed icon (possibly
null
).
- See Also:
setClosedIcon(Icon)
public Icon getDefaultClosedIcon()
Returns the default icon for non-leaf tree cells that are closed (not expanded). The icon is fetched from the defaults table for the currentLookAndFeel
using the keyTree.closedIcon
.
- Returns:
- The default icon.
public Icon getDefaultLeafIcon()
Returns the default icon for leaf tree cells. The icon is fetched from the defaults table for the currentLookAndFeel
using the keyTree.leafIcon
.
- Returns:
- The default icon.
public Icon getDefaultOpenIcon()
Returns the default icon for non-leaf tree cells that are open (expanded). The icon is fetched from the defaults table for the currentLookAndFeel
using the keyTree.openIcon
.
- Returns:
- The default icon.
public Font getFont()
Returns the current font.
- Specified by:
- getFont in interface MenuContainer
- Returns:
- The current font.
- See Also:
setFont(Font)
public Icon getLeafIcon()
Returns the icon displayed for leaf nodes. The default value is initialised from theLookAndFeel
.
- Returns:
- The leaf icon (possibly
null
).
- See Also:
setLeafIcon(Icon)
public Icon getOpenIcon()
Returns the icon displayed for non-leaf nodes that are open (expanded). The default value is initialised from theLookAndFeel
.
- Returns:
- The open icon (possibly
null
).
- See Also:
setOpenIcon(Icon)
public Dimension getPreferredSize()
Returns the preferred size of the cell.
- Overrides:
- getPreferredSize in interface JComponent
- Returns:
- The preferred size of the cell.
public Color getTextNonSelectionColor()
Returns the text color for tree cells that are not selected. The default value is obtained from theLookAndFeel
defaults table using the keyTree.selectionForeground
.
- Returns:
- The background color for tree cells that are not selected.
- See Also:
setTextgroundNonSelectionColor(Color)
public Color getTextSelectionColor()
Returns the text color for tree cells that are selected. The default value is obtained from theLookAndFeel
defaults table using the keyTree.selectionForeground
.
- Returns:
- The text color for tree cells that are selected.
- See Also:
setTextSelectionColor(Color)
public Component getTreeCellRendererComponent(JTree tree, Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
Returns a component (in factthis
) that can be used to render a tree cell with the specified state.
- Specified by:
- getTreeCellRendererComponent in interface TreeCellRenderer
- Parameters:
tree
- the tree that the cell belongs to.val
- the cell value.selected
- indicates whether or not the cell is selected.expanded
- indicates whether or not the cell is expanded.leaf
- indicates whether or not the cell is a leaf in the tree.row
- the row index.hasFocus
- indicates whether or not the cell has the focus.
- Returns:
this
.
public void paint(Graphics g)
Paints the value. The background is filled based on selected.
- Overrides:
- paint in interface JComponent
- Parameters:
g
- the graphics device.
public void repaint(Rectangle area)
For performance reasons, this method is overridden to do nothing.
- Overrides:
- repaint in interface JComponent
- Parameters:
area
- the area to repaint.
public void repaint(long tm, int x, int y, int width, int height)
For performance reasons, this method is overridden to do nothing.
- Overrides:
- repaint in interface JComponent
- Parameters:
tm
- ignoredx
- coordinate of the region to mark as dirtyy
- coordinate of the region to mark as dirtywidth
- dimension of the region to mark as dirtyheight
- dimension of the region to mark as dirty
public void revalidate()
For performance reasons, this method is overridden to do nothing.
- Overrides:
- revalidate in interface JComponent
public void setBackground(Color c)
Sets the background color.
- Overrides:
- setBackground in interface JComponent
- Parameters:
c
- the color.
public void setBackgroundNonSelectionColor(Color c)
Sets the background color for tree cells that are not selected.
- Parameters:
c
- the color (null
permitted).
- See Also:
getBackgroundNonSelectionColor()
public void setBackgroundSelectionColor(Color c)
Sets the background color for tree cells that are selected.
- Parameters:
c
- the color (null
permitted).
- See Also:
getBackgroundSelectionColor()
public void setBorderSelectionColor(Color c)
Sets the border color for tree cells that are selected.
- Parameters:
c
- the color (null
permitted).
- See Also:
getBorderSelectionColor()
public void setClosedIcon(Icon icon)
Sets the icon to be displayed for non-leaf nodes that are closed. Set this tonull
if no icon is required.
- Parameters:
icon
- the icon (null
permitted).
- See Also:
getClosedIcon()
public void setLeafIcon(Icon icon)
Sets the icon to be displayed for leaf nodes. Set this tonull
if no icon is required.
- Parameters:
icon
- the icon (null
permitted).
- See Also:
getLeafIcon()
public void setOpenIcon(Icon icon)
Sets the icon to be displayed for non-leaf nodes that are open (expanded). Set this tonull
if no icon is required.
- Parameters:
icon
- the icon (null
permitted).
- See Also:
getOpenIcon()
public void setTextNonSelectionColor(Color c)
Sets the text color for tree cells that are not selected.
- Parameters:
c
- the color (null
permitted).
- See Also:
getTextNonSelectionColor()
public void setTextSelectionColor(Color c)
Sets the text color for tree cells that are selected.
- Parameters:
c
- the color (null
permitted).
- See Also:
getTextSelectionColor()