所有类


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  Color backgroundNonSelectionColor
          不选定节点时用于背景的颜色。
protected  Color backgroundSelectionColor
          选定节点时用于背景的颜色。
protected  Color borderSelectionColor
          节点具有焦点时,用于焦点指示符的颜色。
protected  Icon closedIcon
          用于显示无扩展的非叶节点的图标。
protected  boolean hasFocus
          如果有焦点,则为 true。
protected  Icon leafIcon
          用于显示叶节点的图标。
protected  Icon openIcon
          用于显示扩展的非叶节点的图标。
protected  boolean selected
          当前是否选择该值。
protected  Color textNonSelectionColor
          用于非选定节点的前景颜色。
protected  Color textSelectionColor
          用于选定节点的前景颜色。
 
从类 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 的新实例。
 
方法摘要
 void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
          因为性能原因而被重写。
 void firePropertyChange(String propertyName, byte oldValue, byte newValue)
          因为性能原因而被重写。
 void firePropertyChange(String propertyName, char oldValue, char newValue)
          因为性能原因而被重写。
 void firePropertyChange(String propertyName, double oldValue, double newValue)
          因为性能原因而被重写。
 void firePropertyChange(String propertyName, float oldValue, float newValue)
          因为性能原因而被重写。
 void firePropertyChange(String propertyName, int oldValue, int newValue)
          因为性能原因而被重写。
 void firePropertyChange(String propertyName, long oldValue, long newValue)
          因为性能原因而被重写。
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          因为性能原因而被重写。
 void firePropertyChange(String propertyName, short oldValue, short newValue)
          因为性能原因而被重写。
 Color getBackgroundNonSelectionColor()
          返回用于非选定节点的背景色。
 Color getBackgroundSelectionColor()
          返回在选定节点的情况下背景所使用的颜色。
 Color getBorderSelectionColor()
          返回绘制边框时所使用的颜色。
 Icon getClosedIcon()
          返回用于表示没有扩展的非叶节点的图标。
 Icon getDefaultClosedIcon()
          返回默认图标,对于当前的 laf,它用于表示没有扩展的非叶节点。
 Icon getDefaultLeafIcon()
          返回默认图标,对于当前的 laf,它用于表示叶节点。
 Icon getDefaultOpenIcon()
          返回默认图标,对于当前的 laf,它用于表示扩展的非叶节点。
 Font getFont()
          获取此组件的字体。
 Icon getLeafIcon()
          返回用于表示叶节点的图标。
 Icon getOpenIcon()
          返回用于表示扩展的非叶节点的图标。
 Dimension getPreferredSize()
          重写 JComponent.getPreferredSize,以返回稍宽的首选大小值。
 Color getTextNonSelectionColor()
          返回未选定节点时绘制文本所使用的颜色。
 Color getTextSelectionColor()
          返回选定节点时绘制文本所使用的颜色。
 Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
          配置基于传入组件的渲染器。
 void invalidate()
          因为性能原因而被重写。
 void paint(Graphics g)
          绘制值。
 void repaint()
          因为性能原因而被重写。
 void repaint(long tm, int x, int y, int width, int height)
          因为性能原因而被重写。
 void repaint(Rectangle r)
          因为性能原因而被重写。
 void revalidate()
          因为性能原因而被重写。
 void setBackground(Color color)
          创建子类,以便将 ColorUIResource 映射为 null。
 void setBackgroundNonSelectionColor(Color newColor)
          设置用于非选定节点的背景色。
 void setBackgroundSelectionColor(Color newColor)
          设置在选定节点的情况下背景所使用的颜色。
 void setBorderSelectionColor(Color newColor)
          设置用于边框的颜色。
 void setClosedIcon(Icon newIcon)
          设置用于表示没有扩展的非叶节点的图标。
 void setFont(Font font)
          创建子类,以便将 FontUIResource 映射为 null。
 void setLeafIcon(Icon newIcon)
          设置用于表示叶节点的图标。
 void setOpenIcon(Icon newIcon)
          设置用于表示扩展的非叶节点的图标。
 void setTextNonSelectionColor(Color newColor)
          设置选定节点时绘制文本所使用的颜色。
 void setTextSelectionColor(Color newColor)
          设置选定节点时绘制文本所使用的颜色。
 void validate()
          因为性能原因而被重写。
 
从类 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
用于非选定节点的前景颜色。

微信小程序

微信扫一扫体验

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部