public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
TreeCellRenderer
interface.JLabel.AccessibleJLabel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
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.
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
DefaultTreeCellRenderer()
Creates a new tree cell renderer with defaults appropriate for the
current
LookAndFeel . |
Modifier and Type | Method and Description |
---|---|
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.
|
void |
firePropertyChange(String name,
long oldValue,
long 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,
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(long tm,
int x,
int y,
int width,
int height)
For performance reasons, this method is overridden to do nothing.
|
void |
repaint(Rectangle area)
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.
|
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected boolean selected
protected boolean hasFocus
protected transient Icon closedIcon
setClosedIcon(Icon)
protected transient Icon leafIcon
setLeafIcon(Icon)
protected transient Icon openIcon
setOpenIcon(Icon)
protected Color textSelectionColor
setTextSelectionColor(Color)
protected Color textNonSelectionColor
setTextNonSelectionColor(Color)
protected Color backgroundSelectionColor
setBackgroundSelectionColor(Color)
protected Color backgroundNonSelectionColor
protected Color borderSelectionColor
setBorderSelectionColor(Color)
public DefaultTreeCellRenderer()
LookAndFeel
.public Icon getDefaultOpenIcon()
LookAndFeel
using the key Tree.openIcon
.public Icon getDefaultClosedIcon()
LookAndFeel
using the key Tree.closedIcon
.public Icon getDefaultLeafIcon()
LookAndFeel
using the key
Tree.leafIcon
.public void setOpenIcon(Icon icon)
null
if no icon is required.icon
- the icon (null
permitted).getOpenIcon()
public Icon getOpenIcon()
LookAndFeel
.null
).setOpenIcon(Icon)
public void setClosedIcon(Icon icon)
null
if no icon is required.icon
- the icon (null
permitted).getClosedIcon()
public Icon getClosedIcon()
LookAndFeel
.null
).setClosedIcon(Icon)
public void setLeafIcon(Icon icon)
null
if no icon is required.icon
- the icon (null
permitted).getLeafIcon()
public Icon getLeafIcon()
LookAndFeel
.null
).setLeafIcon(Icon)
public void setTextSelectionColor(Color c)
c
- the color (null
permitted).getTextSelectionColor()
public Color getTextSelectionColor()
LookAndFeel
defaults
table using the key Tree.selectionForeground
.setTextSelectionColor(Color)
public void setTextNonSelectionColor(Color c)
c
- the color (null
permitted).getTextNonSelectionColor()
public Color getTextNonSelectionColor()
LookAndFeel
defaults
table using the key Tree.selectionForeground
.#setTextgroundNonSelectionColor(Color)
public void setBackgroundSelectionColor(Color c)
c
- the color (null
permitted).getBackgroundSelectionColor()
public Color getBackgroundSelectionColor()
LookAndFeel
defaults
table using the key Tree.selectionBackground
.setBackgroundSelectionColor(Color)
public void setBackgroundNonSelectionColor(Color c)
c
- the color (null
permitted).getBackgroundNonSelectionColor()
public Color getBackgroundNonSelectionColor()
LookAndFeel
defaults
table using the key Tree.textBackground
.setBackgroundNonSelectionColor(Color)
public void setBorderSelectionColor(Color c)
c
- the color (null
permitted).getBorderSelectionColor()
public Color getBorderSelectionColor()
LookAndFeel
defaults
table using the key Tree.selectionBorderColor
.setBorderSelectionColor(Color)
public void setBackground(Color c)
setBackground
in class JComponent
c
- the color.Component.getBackground()
public 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.getTreeCellRendererComponent
in interface TreeCellRenderer
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.this
.public Font getFont()
getFont
in interface MenuContainer
getFont
in class Component
setFont(Font)
public void paint(Graphics g)
paint
in class JComponent
g
- the graphics device.JComponent.paintImmediately(Rectangle)
public Dimension getPreferredSize()
getPreferredSize
in class JComponent
Component.setPreferredSize(java.awt.Dimension)
,
Component.getPreferredSize()
,
Component.isPreferredSizeSet()
,
ComponentUI.getPreferredSize(JComponent)
public void validate()
validate
in class Container
Component.invalidate()
,
Component.doLayout()
,
LayoutManager
,
Container.validate()
public void revalidate()
revalidate
in class JComponent
public void repaint(long tm, int x, int y, int width, int height)
repaint
in class JComponent
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 dirtyComponent.update(Graphics)
public void repaint(Rectangle area)
repaint
in class JComponent
area
- the area to repaint.protected void firePropertyChange(String name, Object oldValue, Object newValue)
firePropertyChange
in class Component
name
- the property name.oldValue
- the old value.newValue
- the new value.public void firePropertyChange(String name, byte oldValue, byte newValue)
firePropertyChange
in class Component
name
- the property name.oldValue
- the old value.newValue
- the new value.public void firePropertyChange(String name, char oldValue, char newValue)
firePropertyChange
in class Component
name
- the property name.oldValue
- the old value.newValue
- the new value.public void firePropertyChange(String name, short oldValue, short newValue)
firePropertyChange
in class Component
name
- the property name.oldValue
- the old value.newValue
- the new value.public void firePropertyChange(String name, int oldValue, int newValue)
firePropertyChange
in class JComponent
name
- the property name.oldValue
- the old value.newValue
- the new value.public void firePropertyChange(String name, long oldValue, long newValue)
firePropertyChange
in class Component
name
- the property name.oldValue
- the old value.newValue
- the new value.public void firePropertyChange(String name, float oldValue, float newValue)
firePropertyChange
in class Component
name
- the property name.oldValue
- the old value.newValue
- the new value.public void firePropertyChange(String name, double oldValue, double newValue)
firePropertyChange
in class Component
name
- the property name.oldValue
- the old value.newValue
- the new value.public void firePropertyChange(String name, boolean oldValue, boolean newValue)
firePropertyChange
in class JComponent
name
- the property name.oldValue
- the old value.newValue
- the new value.