public class MetalTreeUI extends BasicTreeUI
TreeUI
。
MetalTreeUI
允许配置如何可视化地渲染节点之间的间距和描画。 支持以下提示:
Angled
A line is drawn connecting the child to the parent. For handling of the root node refer toJTree.setRootVisible(boolean)
and JTree.setShowsRootHandles(boolean)
. Horizontal
A horizontal line is drawn dividing the children of the root node.None
Do not draw any visual indication between nodes. 由于它一般是不切实际获得TreeUI
从JTree
并浇铸成的实例MetalTreeUI
启用通过客户端属性这个属性JTree.lineStyle
。 例如,要切换到Horizontal
样式,您可以执行以下操作: tree.putClientProperty("JTree.lineStyle", "Horizontal");
默认值为Angled
。
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
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
Constructor and Description |
---|
MetalTreeUI() |
Modifier and Type | Method and Description |
---|---|
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)
涂抹腿部的水平部分。
|
protected void |
paintHorizontalSeparators(Graphics g, JComponent c) |
protected void |
paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)
涂上腿部的垂直部分。
|
void |
uninstallUI(JComponent c)
在installUI中反转在
installUI 上完成的
installUI 。
|
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, getDropLineRect, getEditingPath, getExpandedIcon, getHashColor, getLastChildPath, getLeadSelectionRow, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathBounds, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getRowX, getSelectionModel, getShowsRootHandles, getVerticalLegBuffer, handleExpandControlClick, installComponents, installDefaults, installKeyboardActions, installListeners, isDropLine, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isMultiSelectEvent, isRootVisible, isToggleEvent, isToggleSelectionEvent, paintDropLine, 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, updateLeadSelectionRow, updateRenderer, updateSize
contains, getAccessibleChild, getAccessibleChildrenCount, update
public static ComponentUI createUI(JComponent x)
protected int getHorizontalLegBuffer()
BasicTreeUI
public void installUI(JComponent c)
ComponentUI
ComponentUI
实例作为指定组件上的UI委托时,将调用此方法。
该方法应该完全配置组件的外观,包括以下内容:
LayoutManager
上安装LayoutManager。 PropertyChangeListener
上创建/安装PropertyChangeListener,以便适当地检测和响应组件属性更改。 installUI
在类
BasicTreeUI
c
- 正在安装此UI代理的组件
ComponentUI.uninstallUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void uninstallUI(JComponent c)
ComponentUI
installUI
上完成的installUI
。
当这个UIComponent
实例作为指定组件的UI委托被删除时,将调用此方法。
该方法应该撤消在installUI中执行的installUI
,小心使JComponent
实例处于干净状态(无外部监听器,外观特定属性对象等)。
这应该包括以下内容:
uninstallUI
在
BasicTreeUI
c
- 删除此UI代理的组件;
这个参数经常被忽略,但如果UI对象是无状态的并且被多个组件共享,则可能会被使用
ComponentUI.installUI(javax.swing.JComponent)
,
JComponent.updateUI()
protected void decodeLineStyle(Object lineStyleFlag)
protected boolean isLocationInExpandControl(int row, int rowLevel, int mouseX, int mouseY)
public void paint(Graphics g, JComponent c)
ComponentUI
ComponentUI.update
方法调用。
子类应该覆盖此方法,并使用指定的Graphics
对象来呈现Graphics
的内容。
paint
在
BasicTreeUI
g
- 要绘画的
Graphics
上下文
c
- 正在涂漆的部件
这个参数经常被忽略,但如果UI对象是无状态的并且被多个组件共享,则可能会被使用
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
protected void paintHorizontalSeparators(Graphics g, JComponent c)
protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)
BasicTreeUI
clipBounds
, insets
。
protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
BasicTreeUI
clipBounds
或insets
。
注意:如果根目录不可见, parentRow
可以为-1。