java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.TreeUI
javax.swing.plaf.basic.BasicTreeUI
javax.swing.plaf.metal.MetalTreeUI
TreeUI
的金属外观实现。
MetalTreeUI
允许配置如何在节点之间视觉上呈现间距和分隔。支持以下提示:
提示 | 描述 |
---|---|
Angled | 绘制连接子节点和父节点的线条。有关根节点处理,请参考JTree.setRootVisible(boolean) 和JTree.setShowsRootHandles(boolean) 。 |
Horizontal | 绘制水平线,分隔根节点的子节点。 |
None | 不绘制节点之间的任何视觉指示。 |
由于通常无法从JTree
获取TreeUI
并将其转换为MetalTreeUI
的实例,您可以通过客户端属性JTree.lineStyle
启用此属性。例如,要切换到Horizontal
样式,您可以执行:tree.putClientProperty("JTree.lineStyle", "Horizontal");
默认为Angled
。
-
Nested Class Summary
Nested classes/interfaces declared in class 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
-
Field Summary
Fields declared in class 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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ComponentUI
构造MetalTreeUI
。protected void
decodeLineStyle
(Object lineStyleFlag) 将传递给客户端属性的字符串与内部表示(当前为int)之间进行转换。protected boolean
isLocationInExpandControl
(int row, int rowLevel, int mouseX, int mouseY) 如果具有X坐标mouseX
和Y坐标mouseY
的点位于展开控件中,则返回true
。protected void
绘制水平分隔线。Methods declared in class 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, getDropLineRect, getEditingPath, getExpandedIcon, getHashColor, getHorizontalLegBuffer, 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, paintHorizontalPartOfLeg, paintRow, paintVerticalLine, paintVerticalPartOfLeg, 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
Methods declared in class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, installUI, paint, uninstallUI, update
-
Constructor Details
-
MetalTreeUI
public MetalTreeUI()构造MetalTreeUI
。
-
-
Method Details
-
createUI
构造MetalTreeUI
。- 参数:
-
x
- 一个组件 - 返回:
-
MetalTreeUI
的实例
-
decodeLineStyle
将传递给客户端属性的字符串与内部表示(当前为int)之间进行转换。- 参数:
-
lineStyleFlag
- 一个标志
-
isLocationInExpandControl
protected boolean isLocationInExpandControl(int row, int rowLevel, int mouseX, int mouseY) 如果具有X坐标mouseX
和Y坐标mouseY
的点位于展开控件中,则返回true
。- 参数:
-
row
- 一行 -
rowLevel
- 一行级别 -
mouseX
- X坐标 -
mouseY
- Y坐标 - 返回:
-
如果具有X坐标
mouseX
和Y坐标mouseY
的点位于展开控件中,则返回true
。
-
paintHorizontalSeparators
绘制水平分隔线。- 参数:
-
g
-Graphics
的实例 -
c
- 一个组件
-