所有类


javax.swing.tree
类 DefaultTreeCellRenderer

java.lang.Object
  继承者 java.awt.Component
      继承者 java.awt.Container
          继承者 javax.swing.JComponent
              继承者 javax.swing.JLabel
                  继承者 javax.swing.tree.DefaultTreeCellRenderer
所有已实现的接口:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants, TreeCellRenderer

public class DefaultTreeCellRenderer
   
   
   
   
extends JLabel
implements TreeCellRenderer

显示树中的条目。DefaultTreeCellRenderer 是透明的,除非为 paint 创建子类,否则不要更改它。有关使用此类自定义节点显示的示例,请参阅《The Java Tutorial》中的 How to Use Trees 一节。

实现注意事项:此类重写 invalidatevalidaterevalidaterepaintfirePropertyChange 只是为了提高性能。如果不重写这些方法,这些经常调用的方法将执行那些对于默认树单元格渲染器来说不必要的代码路径。如果编写自己的渲染器,则要小心权衡重写这些方法的利弊。

警告:此类的已序列化对象与以后的 Swing 版本不兼容。当前的序列化支持适用于短期存储或运行相同 Swing 版本的应用程序之间的 RMI。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder


嵌套类摘要
 
从类 javax.swing.JLabel 继承的嵌套类/接口
JLabel.AccessibleJLabel
 
从类 javax.swing.JComponent 继承的嵌套类/接口
JComponent.AccessibleJComponent
 
从类 java.awt.Container 继承的嵌套类/接口
Container.AccessibleAWTContainer
 
从类 java.awt.Component 继承的嵌套类/接口
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
字段摘要
protected  ColorbackgroundNonSelectionColor
          不选定节点时用于背景的颜色。
protected  ColorbackgroundSelectionColor
          选定节点时用于背景的颜色。
protected  ColorborderSelectionColor
          节点具有焦点时,用于焦点指示符的颜色。
protected  IconclosedIcon
          用于显示无扩展的非叶节点的图标。
protected  booleanhasFocus
          如果有焦点,则为 true。
protected  IconleafIcon
          用于显示叶节点的图标。
protected  IconopenIcon
          用于显示扩展的非叶节点的图标。
protected  booleanselected
          当前是否选择该值。
protected  ColortextNonSelectionColor
          用于非选定节点的前景颜色。
protected  ColortextSelectionColor
          用于选定节点的前景颜色。
 
从类 javax.swing.JLabel 继承的字段
labelFor
 
从类 javax.swing.JComponent 继承的字段
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
从类 java.awt.Component 继承的字段
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
从接口 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
 
从接口 java.awt.image.ImageObserver 继承的字段
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
构造方法摘要
DefaultTreeCellRenderer()
          返回 DefaultTreeCellRenderer 的新实例。
 
方法摘要
 voidfirePropertyChange(String propertyName, boolean oldValue, boolean newValue)
          因为性能原因而被重写。
 voidfirePropertyChange(String propertyName, byte oldValue, byte newValue)
          因为性能原因而被重写。
 voidfirePropertyChange(String propertyName, char oldValue, char newValue)
          因为性能原因而被重写。
 voidfirePropertyChange(String propertyName, double oldValue, double newValue)
          因为性能原因而被重写。
 voidfirePropertyChange(String propertyName, float oldValue, float newValue)
          因为性能原因而被重写。
 voidfirePropertyChange(String propertyName, int oldValue, int newValue)
          因为性能原因而被重写。
 voidfirePropertyChange(String propertyName, long oldValue, long newValue)
          因为性能原因而被重写。
protected  voidfirePropertyChange(String propertyName, Object oldValue, Object newValue)
          因为性能原因而被重写。
 voidfirePropertyChange(String propertyName, short oldValue, short newValue)
          因为性能原因而被重写。
 ColorgetBackgroundNonSelectionColor()
          返回用于非选定节点的背景色。
 ColorgetBackgroundSelectionColor()
          返回在选定节点的情况下背景所使用的颜色。
 ColorgetBorderSelectionColor()
          返回绘制边框时所使用的颜色。
 IcongetClosedIcon()
          返回用于表示没有扩展的非叶节点的图标。
 IcongetDefaultClosedIcon()
          返回默认图标,对于当前的 laf,它用于表示没有扩展的非叶节点。
 IcongetDefaultLeafIcon()
          返回默认图标,对于当前的 laf,它用于表示叶节点。
 IcongetDefaultOpenIcon()
          返回默认图标,对于当前的 laf,它用于表示扩展的非叶节点。
 FontgetFont()
          获取此组件的字体。
 IcongetLeafIcon()
          返回用于表示叶节点的图标。
 IcongetOpenIcon()
          返回用于表示扩展的非叶节点的图标。
 DimensiongetPreferredSize()
          重写 JComponent.getPreferredSize,以返回稍宽的首选大小值。
 ColorgetTextNonSelectionColor()
          返回未选定节点时绘制文本所使用的颜色。
 ColorgetTextSelectionColor()
          返回选定节点时绘制文本所使用的颜色。
 ComponentgetTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
          配置基于传入组件的渲染器。
 voidinvalidate()
          因为性能原因而被重写。
 voidpaint(Graphics g)
          绘制值。
 voidrepaint()
          因为性能原因而被重写。
 voidrepaint(long tm, int x, int y, int width, int height)
          因为性能原因而被重写。
 voidrepaint(Rectangle r)
          因为性能原因而被重写。
 voidrevalidate()
          因为性能原因而被重写。
 voidsetBackground(Color color)
          创建子类,以便将 ColorUIResource 映射为 null。
 voidsetBackgroundNonSelectionColor(Color newColor)
          设置用于非选定节点的背景色。
 voidsetBackgroundSelectionColor(Color newColor)
          设置在选定节点的情况下背景所使用的颜色。
 voidsetBorderSelectionColor(Color newColor)
          设置用于边框的颜色。
 voidsetClosedIcon(Icon newIcon)
          设置用于表示没有扩展的非叶节点的图标。
 voidsetFont(Font font)
          创建子类,以便将 FontUIResource 映射为 null。
 voidsetLeafIcon(Icon newIcon)
          设置用于表示叶节点的图标。
 voidsetOpenIcon(Icon newIcon)
          设置用于表示扩展的非叶节点的图标。
 voidsetTextNonSelectionColor(Color newColor)
          设置选定节点时绘制文本所使用的颜色。
 voidsetTextSelectionColor(Color newColor)
          设置选定节点时绘制文本所使用的颜色。
 voidvalidate()
          因为性能原因而被重写。
 
从类 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, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
 
从类 javax.swing.JComponent 继承的方法
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, 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, processMouseEvent, 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, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
从类 java.awt.Container 继承的方法
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, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validateTree
 
从类 java.awt.Component 继承的方法
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, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

selected

protected boolean selected
当前是否选择该值。


hasFocus

protected boolean hasFocus
如果有焦点,则为 true。


closedIcon

protected transient Icon closedIcon
用于显示无扩展的非叶节点的图标。


leafIcon

protected transient Icon leafIcon
用于显示叶节点的图标。


openIcon

protected transient Icon openIcon
用于显示扩展的非叶节点的图标。


textSelectionColor

protected Color textSelectionColor
用于选定节点的前景颜色。


textNonSelectionColor

protected Color textNonSelectionColor
用于非选定节点的前景颜色。