- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.TreeUI
-
- javax.swing.plaf.basic.BasicTreeUI
-
- javax.swing.plaf.synth.SynthTreeUI
-
- All Implemented Interfaces:
-
PropertyChangeListener
,EventListener
,SynthConstants
,SynthUI
public class SynthTreeUI extends BasicTreeUI implements PropertyChangeListener, SynthUI
为JTree
提供Synth L&F UI代表。- 从以下版本开始:
- 1.7
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from 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 inherited from 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
-
Fields inherited from interface javax.swing.plaf.synth.SynthConstants
DEFAULT, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED, SELECTED
-
-
构造方法摘要
构造方法 Constructor 描述 SynthTreeUI()
-
方法摘要
所有方法 静态方法 接口方法 具体的方法 Modifier and Type 方法 描述 protected TreeCellEditor
createDefaultCellEditor()
创建默认单元格编辑器。protected TreeCellRenderer
createDefaultCellRenderer()
返回用于执行每个节点冲压的默认单元格渲染器。static ComponentUI
createUI(JComponent x)
为给定的组件创建一个新的UI对象。protected void
drawCentered(Component c, Graphics graphics, Icon icon, int x, int y)
以(x,y)为中心绘制icon
。SynthContext
getContext(JComponent c)
返回指定组件的上下文。Icon
getExpandedIcon()
返回展开的图标。protected int
getRowX(int row, int depth)
返回沿x轴的位置,以呈现特定的行。protected void
installDefaults()
安装默认属性。protected void
installListeners()
注册听众。void
paint(Graphics g, JComponent c)
根据外观和外观绘制指定的组件。protected void
paint(SynthContext context, Graphics g)
绘制指定的组件。void
paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)
画边框protected void
paintDropLine(Graphics g)
画下线。protected void
paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
绘制一行的展开(切换)部分。protected void
paintHorizontalLine(Graphics g, JComponent c, int y, int left, int right)
画一条水平线。protected void
paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
涂抹腿部的水平部分。protected void
paintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom)
画一条垂直线。protected void
paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)
涂上腿部的垂直部分。void
propertyChange(PropertyChangeEvent event)
当绑定属性更改时,此方法将被调用。protected void
uninstallDefaults()
卸载默认属性。protected void
uninstallListeners()
取消注册听众。void
update(Graphics g, JComponent c)
通知此UI代理重新绘制指定的组件。-
Methods inherited from class javax.swing.plaf.basic.BasicTreeUI
cancelEditing, checkForClickInExpandControl, completeEditing, completeEditing, completeUIInstall, completeUIUninstall, configureLayoutCache, createCellEditorListener, createCellRendererPane, createComponentListener, createFocusListener, createKeyListener, createLayoutCache, createMouseListener, createNodeDimensions, createPropertyChangeListener, createSelectionModelPropertyChangeListener, createTreeExpansionListener, createTreeModelListener, createTreeSelectionListener, drawDashedHorizontalLine, drawDashedVerticalLine, ensureRowsAreVisible, getBaseline, getBaselineResizeBehavior, getCellEditor, getCellRenderer, getClosestPathForLocation, getCollapsedIcon, getDropLineRect, getEditingPath, getHashColor, getHorizontalLegBuffer, getLastChildPath, getLeadSelectionRow, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathBounds, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getSelectionModel, getShowsRootHandles, getVerticalLegBuffer, handleExpandControlClick, installComponents, installKeyboardActions, installUI, isDropLine, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isMultiSelectEvent, isRootVisible, isToggleEvent, isToggleSelectionEvent, paintRow, 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, uninstallKeyboardActions, uninstallUI, updateCachedPreferredSize, updateCellEditor, updateDepthOffset, updateExpandedDescendants, updateLayoutCacheExpandedNodes, updateLeadSelectionRow, updateRenderer, updateSize
-
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount
-
-
-
-
方法详细信息
-
createUI
public static ComponentUI createUI(JComponent x)
为给定的组件创建一个新的UI对象。- 参数
-
x
- 为其创建UI对象的组件 - 结果
- UI对象
-
getExpandedIcon
public Icon getExpandedIcon()
返回展开的图标。- 重写:
-
getExpandedIcon
在BasicTreeUI
- 结果
- 扩展图标
-
installDefaults
protected void installDefaults()
安装默认属性。
-
installListeners
protected void installListeners()
注册听众。
-
getContext
public SynthContext getContext(JComponent c)
返回指定组件的上下文。- Specified by:
-
getContext
在接口SynthUI
- 参数
-
c
- 组件请求SynthContext。 - 结果
- SynthContext描述组件。
-
createDefaultCellEditor
protected TreeCellEditor createDefaultCellEditor()
创建默认单元格编辑器。- 重写:
-
createDefaultCellEditor
在BasicTreeUI
- 结果
- 默认单元格编辑器
-
createDefaultCellRenderer
protected TreeCellRenderer createDefaultCellRenderer()
返回用于执行每个节点冲压的默认单元格渲染器。- 重写:
-
createDefaultCellRenderer
在BasicTreeUI
- 结果
-
一个
TreeCellRenderer
-
uninstallDefaults
protected void uninstallDefaults()
卸载默认属性。
-
uninstallListeners
protected void uninstallListeners()
取消注册听众。
-
update
public void update(Graphics g, JComponent c)
通知此UI代理重新绘制指定的组件。 此方法绘制组件背景,然后调用paint(SynthContext,Graphics)
方法。通常,此方法不需要被子类覆盖。 所有的Look和Feel渲染代码都应该在
paint
。- 重写:
-
update
在ComponentUI
- 参数
-
g
- 用于绘画的Graphics
对象 -
c
- 正在涂漆的组件 - 另请参见:
-
paint(SynthContext,Graphics)
-
paintBorder
public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)
画边框- Specified by:
-
paintBorder
在接口SynthUI
- 参数
-
context
- 组件上下文 -
g
-Graphics
上画 -
x
- X坐标 -
y
- Y坐标 -
w
- 边框的宽度 -
h
- 边框的高度
-
paint
public void paint(Graphics g, JComponent c)
根据外观和外观绘制指定的组件。Synth Look and Feel不使用此方法。 绘画由
paint(SynthContext,Graphics)
处理。- 重写:
-
paint
在BasicTreeUI
- 参数
-
g
- 用于绘画的Graphics
对象 -
c
- 正在涂漆的组件 - 另请参见:
-
paint(SynthContext,Graphics)
-
paint
protected void paint(SynthContext context, Graphics g)
绘制指定的组件。- 参数
-
context
- 正在绘制的组件的上下文 -
g
- 用于绘画的Graphics
对象 - 另请参见:
-
update(Graphics,JComponent)
-
paintHorizontalPartOfLeg
protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
涂抹腿部的水平部分。 接收方不应修改clipBounds
或insets
。注意:如果根目录不可见,则
parentRow
可以为-1。- 重写:
-
paintHorizontalPartOfLeg
在BasicTreeUI
- 参数
-
g
- 图形上下文 -
clipBounds
- 一个剪切的矩形 -
insets
- 插图 -
bounds
- 一个边界矩形 -
path
- 树路径 -
row
- 一排 -
isExpanded
-true
如果路径被扩展 -
hasBeenExpanded
-true
如果路径已被扩展 -
isLeaf
-true
如果路径是叶
-
paintHorizontalLine
protected void paintHorizontalLine(Graphics g, JComponent c, int y, int left, int right)
画一条水平线。- 重写:
-
paintHorizontalLine
在BasicTreeUI
- 参数
-
g
- 图形上下文 -
c
- 一个组件 -
y
- 一个Y坐标 -
left
- X1坐标 -
right
- X2坐标
-
paintVerticalPartOfLeg
protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)
涂上腿部的垂直部分。 该接收器不应修改clipBounds
,insets
。- 重写:
-
paintVerticalPartOfLeg
在BasicTreeUI
- 参数
-
g
- 图形上下文 -
clipBounds
- 一个剪切的矩形 -
insets
- 插图 -
path
- 树路径
-
paintVerticalLine
protected void paintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom)
画一条垂直线。- 重写:
-
paintVerticalLine
在BasicTreeUI
- 参数
-
g
- 图形上下文 -
c
- 一个组件 -
x
- X坐标 -
top
- 一个Y1坐标 -
bottom
- 一个Y2坐标
-
paintExpandControl
protected void paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
绘制一行的展开(切换)部分。 接收方不应修改clipBounds
或insets
。- 重写:
-
paintExpandControl
在BasicTreeUI
- 参数
-
g
- 图形上下文 -
clipBounds
- 一个剪切的矩形 -
insets
- 插图 -
bounds
- 一个边界矩形 -
path
- 树路径 -
row
- 一排 -
isExpanded
-true
如果路径被扩展 -
hasBeenExpanded
-true
如果路径已被扩展 -
isLeaf
-true
如果行是叶
-
drawCentered
protected void drawCentered(Component c, Graphics graphics, Icon icon, int x, int y)
绘制以(x,y)为中心的icon
。- 重写:
-
drawCentered
在BasicTreeUI
- 参数
-
c
- 一个组件 -
graphics
- 图形上下文 -
icon
- 一个图标 -
x
- 一个X坐标 -
y
- 一个Y坐标
-
propertyChange
public void propertyChange(PropertyChangeEvent event)
当绑定属性更改时,此方法将被调用。- Specified by:
-
propertyChange
在接口PropertyChangeListener
- 参数
-
event
- 描述事件源和已更改的属性的PropertyChangeEvent对象。
-
paintDropLine
protected void paintDropLine(Graphics g)
画下线。- 重写:
-
paintDropLine
在BasicTreeUI
- 参数
-
g
-Graphics
对象绘制
-
getRowX
protected int getRowX(int row, int depth)
返回沿x轴的位置,以呈现特定的行。 返回值不包括JTree上指定的任何Insets。 这不检查行或深度的有效性,假设它是正确的,如果行或深度与树的行或深度不匹配,则不会抛出异常。- 重写:
-
getRowX
在BasicTreeUI
- 参数
-
row
- 返回x位置的行 -
depth
- 行的深度 - 结果
- 相当于给定行缩进。
-
-