JavaTM 2 Platform
Standard Ed. 6

javax.swing.plaf.metal
类 MetalTreeUI

java.lang.Object
  继承者 javax.swing.plaf.ComponentUI
      继承者 javax.swing.plaf.TreeUI
          继承者 javax.swing.plaf.basic.BasicTreeUI
              继承者 javax.swing.plaf.metal.MetalTreeUI

public class MetalTreeUI
extends BasicTreeUI

TreeUI 的 metal 外观实现。

MetalTreeUI 允许配置如何在视觉上呈现节点之间的间隔和描绘。支持以下提示:

Angled

绘制一条连接子节点和父节点的线。关于如何处理根节点,请参阅 JTree.setRootVisible(boolean)JTree.setShowsRootHandles(boolean)

Horizontal

绘制用来分隔根节点的子节点的一条水平线。

None

不在节点间绘制任何可见的指示。

因为通常无法从 JTree 中获得 TreeUI 并将它强制转换成 MetalTreeUI 实例,所以要通过客户端属性 JTree.lineStyle 启用此属性。例如,要切换成 Horizontal 风格,需要这样做:tree.putClientProperty("JTree.lineStyle", "Horizontal");

默认值为 Angled


嵌套类摘要
 
从类 javax.swing.plaf.basic.BasicTreeUI 继承的嵌套类/接口
BasicTreeUI.CellEditorHandler, BasicTreeUI.ComponentHandler, BasicTreeUI.FocusHandler, BasicTreeUI.KeyHandler, BasicTreeUI.MouseHandler, BasicTreeUI.MouseInputHandler, BasicTreeUI.NodeDimensionsHandler, BasicTreeUI.PropertyChangeHandler, BasicTreeUI.SelectionModelPropertyChangeHandler, BasicTreeUI.TreeCancelEditingAction, BasicTreeUI.TreeExpansionHandler, BasicTreeUI.TreeHomeAction, BasicTreeUI.TreeIncrementAction, BasicTreeUI.TreeModelHandler, BasicTreeUI.TreePageAction, BasicTreeUI.TreeSelectionHandler, BasicTreeUI.TreeToggleAction, BasicTreeUI.TreeTraverseAction
 
字段摘要
 
从类 javax.swing.plaf.basic.BasicTreeUI 继承的字段
cellEditor, collapsedIcon, createdCellEditor, createdRenderer, currentCellRenderer, depthOffset, drawingCache, editingComponent, editingPath, editingRow, editorHasDifferentSize, expandedIcon, largeModel, lastSelectedRow, leftChildIndent, nodeDimensions, preferredMinSize, preferredSize, rendererPane, rightChildIndent, stopEditingInCompleteEditing, totalChildIndent, tree, treeModel, treeSelectionModel, treeState, validCachedPreferredSize
 
构造方法摘要
MetalTreeUI()
           
 
方法摘要
static ComponentUI createUI(JComponent x)
           
protected  void decodeLineStyle(Object lineStyleFlag)
          此方法进行传入客户端属性中的字符串和内部表示形式(当前的并且用 int 值表示)之间的转换
protected  int getHorizontalLegBuffer()
          默认情况下,节点间支路的水平元素开始于子节点左侧的右边。
 void installUI(JComponent c)
          配置指定组件,使其适合外观。
protected  boolean isLocationInExpandControl(int row, int rowLevel, int mouseX, int mouseY)
           
 void paint(Graphics g, JComponent c)
          绘制指定组件,使其适合外观。
protected  void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
          绘制支路 (leg) 的水平部分。
protected  void paintHorizontalSeparators(Graphics g, JComponent c)
           
protected  void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)
          绘制支路的垂直部分。
 void uninstallUI(JComponent c)
          在 installUI 期间,在指定组件上反向执行的配置操作。
 
从类 javax.swing.plaf.basic.BasicTreeUI 继承的方法
cancelEditing, checkForClickInExpandControl, completeEditing, completeEditing, completeUIInstall, completeUIUninstall, configureLayoutCache, createCellEditorListener, createCellRendererPane, createComponentListener, createDefaultCellEditor, createDefaultCellRenderer, createFocusListener, createKeyListener, createLayoutCache, createMouseListener, createNodeDimensions, createPropertyChangeListener, createSelectionModelPropertyChangeListener, createTreeExpansionListener, createTreeModelListener, createTreeSelectionListener, drawCentered, drawDashedHorizontalLine, drawDashedVerticalLine, ensureRowsAreVisible, getBaseline, getBaselineResizeBehavior, getCellEditor, getCellRenderer, getClosestPathForLocation, getCollapsedIcon, getEditingPath, getExpandedIcon, getHashColor, getLastChildPath, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathBounds, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getRowX, getSelectionModel, getShowsRootHandles, getVerticalLegBuffer, handleExpandControlClick, installComponents, installDefaults, installKeyboardActions, installListeners, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isMultiSelectEvent, isRootVisible, isToggleEvent, isToggleSelectionEvent, paintExpandControl, paintHorizontalLine, paintRow, paintVerticalLine, pathWasCollapsed, pathWasExpanded, prepareForUIInstall, prepareForUIUninstall, selectPathForEvent, setCellEditor, setCellRenderer, setCollapsedIcon, setEditable, setExpandedIcon, setHashColor, setLargeModel, setLeftChildIndent, setModel, setPreferredMinSize, setRightChildIndent, setRootVisible, setRowHeight, setSelectionModel, setShowsRootHandles, shouldPaintExpandControl, startEditing, startEditingAtPath, stopEditing, toggleExpandState, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, updateCachedPreferredSize, updateCellEditor, updateDepthOffset, updateExpandedDescendants, updateLayoutCacheExpandedNodes, updateRenderer, updateSize
 
从类 javax.swing.plaf.ComponentUI 继承的方法
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

MetalTreeUI

public MetalTreeUI()
方法详细信息

createUI

public static ComponentUI createUI(JComponent x)

getHorizontalLegBuffer

protected int getHorizontalLegBuffer()
从类 BasicTreeUI 复制的描述
默认情况下,节点间支路的水平元素开始于子节点左侧的右边。此方法能让支路在该位置以前结束。

覆盖:
BasicTreeUI 中的 getHorizontalLegBuffer

installUI

public void installUI(JComponent c)
从类 ComponentUI 复制的描述
配置指定组件,使其适合外观。当 ComponentUI 实例将作为 UI 委托安装在指定组件上时,可调用此方法。此方法应该为外观完整地配置组件,包括以下方面:
  1. 在组件上安装用于颜色、字体、边框、图标、不透明性等方面的所有默认属性值。只要有可能,就 应该重写由客户端程序初始化的属性值。
  2. 如有必要,可在组件上安装一个 LayoutManager
  3. 将所需的所有子组件创建/添加到组件中。
  4. 在组件上创建/安装事件侦听器。
  5. 为了检测和适当响应组件属性更改,可在组件上创建/安装一个 PropertyChangeListener
  6. 在组件上安装键盘 UI(助记符、遍历等等)。
  7. 初始化任何适当的实例数据。

覆盖:
BasicTreeUI 中的 installUI
参数:
c - 将安装此 UI 委托的组件
另请参见:
ComponentUI.uninstallUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

uninstallUI

public void uninstallUI(JComponent c)
从类 ComponentUI 复制的描述
installUI 期间,在指定组件上反向执行的配置操作。当此 UIComponent 实例将作为 UI 委托从指定组件上移除时,可调用此方法。此方法应该取消在 installUI 中执行的配置操作,非常小心地使 JComponent 实例处于某种洁净状态(没有额外的侦听器、没有特定于外观的属性对象等等)。配置内容应该包括以下方面:
  1. 从组件中移除所有 UI 设置的边框。
  2. 从组件上移除所有 UI 设置的布局管理器。
  3. 从组件中移除所有 UI 添加的子组件。
  4. 从组件中移除所有 UI 添加的事件/属性侦听器。
  5. 从组件中移除所有 UI 安装的键盘 UI。
  6. 使所有已分配的实例数据对象无效,从而允许进行 GC 操作。

覆盖:
BasicTreeUI 中的 uninstallUI
参数:
c - 从中移除此 UI 委托的组件;此参数常被忽略,但如果 UI 对象是无状态的并由多个组件共享,则可以使用该参数
另请参见:
ComponentUI.installUI(javax.swing.JComponent), JComponent.updateUI()

decodeLineStyle

protected void decodeLineStyle(Object lineStyleFlag)
此方法进行传入客户端属性中的字符串和内部表示形式(当前的并且用 int 值表示)之间的转换


isLocationInExpandControl

protected boolean isLocationInExpandControl(int row,
                                            int rowLevel,
                                            int mouseX,
                                            int mouseY)

paint

public void paint(Graphics g,
                  JComponent c)
从类 ComponentUI 复制的描述
绘制指定组件,使其适合外观。在将要绘制指定组件时,从 ComponentUI.update 方法中调用此方法。子类应该重写此方法并使用指定 Graphics 对象来呈现组件的内容。

覆盖:
BasicTreeUI 中的 paint
参数:
g - 将在其中进行绘制的 Graphics 上下文
c - 将绘制的组件;此参数常被忽略,但如果 UI 对象是无状态的并由多个组件共享,则可以使用该参数
另请参见:
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)

paintHorizontalSeparators

protected void paintHorizontalSeparators(Graphics g,
                                         JComponent c)

paintVerticalPartOfLeg

protected void paintVerticalPartOfLeg(Graphics g,
                                      Rectangle clipBounds,
                                      Insets insets,
                                      TreePath path)
从类 BasicTreeUI 复制的描述
绘制支路的垂直部分。接收者不应修改 clipBoundsinsets

覆盖:
BasicTreeUI 中的 paintVerticalPartOfLeg

paintHorizontalPartOfLeg

protected void paintHorizontalPartOfLeg(Graphics g,
                                        Rectangle clipBounds,
                                        Insets insets,
                                        Rectangle bounds,
                                        TreePath path,
                                        int row,
                                        boolean isExpanded,
                                        boolean hasBeenExpanded,
                                        boolean isLeaf)
从类 BasicTreeUI 复制的描述
绘制支路 (leg) 的水平部分。接收者不应修改 clipBoundsinsets

注:如果树不可见,则 parentRow 为 -1。

覆盖:
BasicTreeUI 中的 paintHorizontalPartOfLeg

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策