- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.TreeUI
-
- javax.swing.plaf.basic.BasicTreeUI
-
- 已知直接子类:
-
MetalTreeUI,SynthTreeUI
public class BasicTreeUI extends TreeUI
分层数据结构的基本L&F。
-
-
嵌套类汇总
嵌套类 变量和类型 类 描述 classBasicTreeUI.CellEditorHandler监听器负责获取单元格编辑事件并相应地更新树。classBasicTreeUI.ComponentHandler滚动时更新首选大小(如有必要)。classBasicTreeUI.FocusHandler当失去焦点/获得焦点时重新绘制前导选择行。classBasicTreeUI.KeyHandler这用于获取多个按键事件以适当地生成事件。classBasicTreeUI.MouseHandlerTreeMouseListener负责根据鼠标事件更新选择。classBasicTreeUI.MouseInputHandlerMouseInputHandler处理传递所有鼠标事件,包括鼠标移动事件,直到鼠标被释放到构造它的目标。classBasicTreeUI.NodeDimensionsHandler负责获取节点大小的类,方法转发到BasicTreeUI方法。classBasicTreeUI.PropertyChangeHandler树的PropertyChangeListener。classBasicTreeUI.SelectionModelPropertyChangeHandler如果模型的任何属性发生更改,TreeSelectionModel上的侦听器将重置行选择。classBasicTreeUI.TreeCancelEditingActionActionListener在执行操作时调用cancelEditing。classBasicTreeUI.TreeExpansionHandler更新TreeState以响应节点扩展/折叠。classBasicTreeUI.TreeHomeActionTreeHomeAction用于处理结束/主页操作。classBasicTreeUI.TreeIncrementActionTreeIncrementAction用于处理向上/向下操作。classBasicTreeUI.TreeModelHandler将所有TreeModel事件转发到TreeState。classBasicTreeUI.TreePageActionTreePageAction处理向上翻页和向下翻页事件。classBasicTreeUI.TreeSelectionHandler侦听选择模型中的更改并相应地更新显示。classBasicTreeUI.TreeToggleAction对于第一个选定的行,将切换扩展性。classBasicTreeUI.TreeTraverseActionTreeTraverseAction是用于左/右键的操作。
-
字段汇总
字段 变量和类型 字段 描述 protected TreeCellEditorcellEditor树的编辑。protected IconcollapsedIcon折叠的图标。protected booleancreatedCellEditor如果此实例创建了当前位于树中的编辑器,则设置为true。protected booleancreatedRenderer如果此实例创建当前位于树中的渲染器,则设置为true。protected TreeCellRenderercurrentCellRenderer用于进行实际单元格绘制的渲染器。protected intdepthOffset为了正确计算x位置,应该偏移多少深度。protected Hashtable<TreePath,Boolean>drawingCache用于最小化垂直线的绘制。protected ComponenteditingComponent编辑时,这将是正在进行实际编辑的组件。protected TreePatheditingPath正在编辑的路径。protected inteditingRow正在编辑的行。protected booleaneditorHasDifferentSize如果编辑器的大小与渲染器的大小不同,则设置为true。protected IconexpandedIcon展开的图标。protected booleanlargeModel如果对largeModel进行优化,则为True。protected intlastSelectedRow上次选择的行的索引。protected intleftChildIndent左边距与垂直破折号之间的距离。protected AbstractLayoutCache.NodeDimensionsnodeDimensions负责告诉TreeState节点所需的大小。protected DimensionpreferredMinSize最小首选尺寸。protected DimensionpreferredSize完全显示所有节点所需的大小。protected CellRendererPanerendererPane用于绘制TreeCellRenderer。protected intrightChildIndent要添加到leftChildIndent以确定将绘制单元格内容的位置的距离。protected booleanstopEditingInCompleteEditing编辑时设置为false,而shouldSelectCell()返回true表示在编辑之前应选择节点,用于completeEditing。protected inttotalChildIndent将缩进的总距离。protected JTreetree我们将要绘制的组件。protected TreeModeltreeModel用于确定要显示的内容。protected TreeSelectionModeltreeSelectionModel模型保持选择。protected AbstractLayoutCachetreeState负责处理大小调整和扩展问题的对象。protected booleanvalidCachedPreferredSizepreferredSize有效吗?
-
构造方法摘要
构造方法 构造器 描述 BasicTreeUI()构造BasicTreeUI的新实例。
-
方法摘要
所有方法 静态方法 实例方法 具体的方法 变量和类型 方法 描述 voidcancelEditing(JTree tree)取消当前编辑会话。protected voidcheckForClickInExpandControl(TreePath path, int mouseX, int mouseY)如果mouseX和mouseY都在的展开/折叠区域row,这将切换行。protected voidcompleteEditing()用于停止编辑会话的消息。protected voidcompleteEditing(boolean messageStop, boolean messageCancel, boolean messageTree)停止编辑会话。protected voidcompleteUIInstall()安装完所有默认值/侦听器后从installUI调用。protected voidcompleteUIUninstall()卸载UI。protected voidconfigureLayoutCache()根据我们提供外观的树重置TreeState实例。protected CellEditorListenercreateCellEditorListener()创建一个侦听器来处理当前编辑器中的事件。protected CellRendererPanecreateCellRendererPane()返回放置渲染器组件的渲染器窗格。protected ComponentListenercreateComponentListener()创建并返回一个新的ComponentHandler。protected TreeCellEditorcreateDefaultCellEditor()创建默认单元格编辑器。protected TreeCellRenderercreateDefaultCellRenderer()返回用于对每个节点进行标记的默认单元格渲染器。protected FocusListenercreateFocusListener()创建一个监听器,负责在丢失/获得焦点时更新显示。protected KeyListenercreateKeyListener()创建负责从树中获取关键事件的侦听器。protected AbstractLayoutCachecreateLayoutCache()创建负责管理扩展内容的对象以及节点的大小。protected MouseListenercreateMouseListener()创建负责根据鼠标事件更新选择的侦听器。protected AbstractLayoutCache.NodeDimensionscreateNodeDimensions()创建NodeDimensions的实例,该实例能够确定树中给定节点的大小。protected PropertyChangeListenercreatePropertyChangeListener()创建一个负责的监听器,根据树的更改方式更新UI。protected PropertyChangeListenercreateSelectionModelPropertyChangeListener()创建负责从选择模型获取属性更改事件的侦听器。protected TreeExpansionListenercreateTreeExpansionListener()当节点扩展状态更改时,创建并返回负责更新treestate的对象。protected TreeModelListenercreateTreeModelListener()返回一个侦听器,可以在模型更改时更新树。protected TreeSelectionListenercreateTreeSelectionListener()创建基于选择更改方法更新显示的侦听器。static ComponentUIcreateUI(JComponent x)构造BasicTreeUI的新实例。protected voiddrawCentered(Component c, Graphics graphics, Icon icon, int x, int y)绘制以(x,y)为中心的icon。protected voiddrawDashedHorizontalLine(Graphics g, int y, int x1, int x2)画一条水平虚线。protected voiddrawDashedVerticalLine(Graphics g, int x, int y1, int y2)画一条垂直虚线。protected voidensureRowsAreVisible(int beginRow, int endRow)确保beginRow至endRow标识的行可见。intgetBaseline(JComponent c, int width, int height)返回基线。Component.BaselineResizeBehaviorgetBaselineResizeBehavior(JComponent c)返回一个枚举,指示组件的基线如何随大小的变化而变化。protected TreeCellEditorgetCellEditor()返回TreeCellEditor的实例。protected TreeCellRenderergetCellRenderer()返回currentCellRenderer,它将是树渲染器,或defaultCellRenderer,它们不是null。TreePathgetClosestPathForLocation(JTree tree, int x, int y)返回最接近x,y的节点的路径。IcongetCollapsedIcon()返回折叠的图标。protected RectanglegetDropLineRect(JTree.DropLocation loc)返回下拉线的无限制框。TreePathgetEditingPath(JTree tree)返回正在编辑的元素的路径。IcongetExpandedIcon()返回展开的图标。protected ColorgetHashColor()返回散列颜色。protected intgetHorizontalLegBuffer()默认情况下,节点之间的支路的水平元素从子节点的左侧开始。protected TreePathgetLastChildPath(TreePath parent)返回最后一个子项parent的路径。protected intgetLeadSelectionRow()返回选择的前导行。intgetLeftChildIndent()返回左子缩进。DimensiongetMaximumSize(JComponent c)返回此组件的最大大小,如果实例当前位于JTree中,则该大小将是首选大小,或0,0。DimensiongetMinimumSize(JComponent c)返回此组件的最小大小。protected TreeModelgetModel()返回树模型。RectanglegetPathBounds(JTree tree, TreePath path)返回包含将绘制路径中最后一项的标签部分的Rectangle。TreePathgetPathForRow(JTree tree, int row)返回传入行的路径。DimensiongetPreferredMinSize()返回最小首选大小。DimensiongetPreferredSize(JComponent c)返回正确显示树的首选大小,这是getPreferredSize(c, true)的封面方法。DimensiongetPreferredSize(JComponent c, boolean checkConsistency)返回表示 c中树的首选大小。intgetRightChildIndent()返回正确的子缩进。intgetRowCount(JTree tree)返回正在显示的行数。intgetRowForPath(JTree tree, TreePath path)返回路径中标识的最后一项可见的行。protected intgetRowHeight()返回行高。protected intgetRowX(int row, int depth)返回沿x轴的位置,以呈现特定的行。protected TreeSelectionModelgetSelectionModel()返回树选择模型。protected booleangetShowsRootHandles()如果要显示根句柄,则返回true。protected intgetVerticalLegBuffer()节点之间的腿的垂直元素默认从父节点的底部开始。protected voidhandleExpandControlClick(TreePath path, int mouseX, int mouseY)当用户单击特定行时发送消息,这将调用toggleExpandState。protected voidinstallComponents()Intall树的子组件,即渲染器窗格。protected voidinstallDefaults()安装默认属性。protected voidinstallKeyboardActions()注册键盘操作。protected voidinstallListeners()注册听众。protected booleanisDropLine(JTree.DropLocation loc)告知DropLocation是否应由节点之间的线指示。protected booleanisEditable()如果树可编辑,则返回true。booleanisEditing(JTree tree)如果正在编辑树,则返回true。protected booleanisLargeModel()如果设置了大型模型,则返回true。protected booleanisLeaf(int row)返回true如果在节点row是叶。protected booleanisLocationInExpandControl(TreePath path, int mouseX, int mouseY)返回true如果mouseX和mouseY下降,用于展开/折叠节点和节点的行的区域row不代表叶子。protected booleanisMultiSelectEvent(MouseEvent event)返回true表示节点上的鼠标事件应从锚点中选择。protected booleanisRootVisible()如果树根可见,则返回true。protected booleanisToggleEvent(MouseEvent event)返回true表示应根据事件切换鼠标下的行。protected booleanisToggleSelectionEvent(MouseEvent event)返回true表示节点上的鼠标事件应该仅切换鼠标下的行的选择。protected voidpaintDropLine(Graphics g)画下线。protected voidpaintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)绘制一行的展开(切换)部分。protected voidpaintHorizontalLine(Graphics g, JComponent c, int y, int left, int right)画一条水平线。protected voidpaintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)涂抹腿部的水平部分。protected voidpaintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)绘制一行的渲染器部分。protected voidpaintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom)画一条垂直线。protected voidpaintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)涂抹腿部的垂直部分。protected voidpathWasCollapsed(TreePath path)在它崩溃后从VisibleTreeNode消息。protected voidpathWasExpanded(TreePath path)在VisibleTreeNode后从VisibleTreeNode消息。protected voidprepareForUIInstall()在设置tree实例变量之后但在安装任何默认值/侦听器之前调用。protected voidprepareForUIUninstall()在安装UI之前调用。protected voidselectPathForEvent(TreePath path, MouseEvent event)消息传递以在特定行上基于MouseEvent更新选择。protected voidsetCellEditor(TreeCellEditor editor)设置单元格编辑器。protected voidsetCellRenderer(TreeCellRenderer tcr)将TreeCellRenderer设置为tcr。voidsetCollapsedIcon(Icon newG)设置折叠图标。protected voidsetEditable(boolean newValue)配置接收器允许或不允许编辑。voidsetExpandedIcon(Icon newG)设置展开的图标。protected voidsetHashColor(Color color)设置哈希颜色。protected voidsetLargeModel(boolean largeModel)如有必要,更新componentListener。voidsetLeftChildIndent(int newAmount)设置左子缩进。protected voidsetModel(TreeModel model)设置TreeModel。voidsetPreferredMinSize(Dimension newSize)设置首选最小大小。voidsetRightChildIndent(int newAmount)设置正确的子缩进。protected voidsetRootVisible(boolean newValue)将根设置为可见。protected voidsetRowHeight(int rowHeight)设置行高,将其转发到treeState。protected voidsetSelectionModel(TreeSelectionModel newLSM)重置选择模型。protected voidsetShowsRootHandles(boolean newValue)确定是否显示节点句柄。protected booleanshouldPaintExpandControl(TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)如果应为指定行绘制展开(切换)控件,则返回true。protected booleanstartEditing(TreePath path, MouseEvent event)如果有cellEditor并且shouldSelectCell返回true将开始编辑节点。voidstartEditingAtPath(JTree tree, TreePath path)选择路径中的最后一项并尝试编辑它。booleanstopEditing(JTree tree)停止当前的编辑会话。protected voidtoggleExpandState(TreePath path)如果未展开,则展开路径;如果展开,则展开行。protected voiduninstallComponents()卸载渲染器窗格。protected voiduninstallDefaults()卸载默认属性。protected voiduninstallKeyboardActions()取消注册键盘操作。protected voiduninstallListeners()取消注册听众。protected voidupdateCachedPreferredSize()更新preferredSize实例变量,该变量从getPreferredSize()返回。protected voidupdateCellEditor()根据我们所包含的JTree的可编辑性更新cellEditor。protected voidupdateDepthOffset()更新每个深度应该偏移的程度。protected voidupdateExpandedDescendants(TreePath path)通过从树中获取扩展后代并转发到树状态来更新path的所有后代的展开状态。protected voidupdateLayoutCacheExpandedNodes()使所有在JTree中扩展的节点在LayoutCache中扩展。protected voidupdateLeadSelectionRow()更新选择的前导行。protected voidupdateRenderer()当渲染器发生变化时,我们从树中传来消息。protected voidupdateSize()将缓存的大小标记为无效,并使用treeDidChange向树发送消息。-
声明方法的类 javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, installUI, paint, uninstallUI, update
-
-
-
-
字段详细信息
-
collapsedIcon
protected transient Icon collapsedIcon
折叠的图标。
-
expandedIcon
protected transient Icon expandedIcon
展开的图标。
-
leftChildIndent
protected int leftChildIndent
左边距与垂直破折号之间的距离。
-
rightChildIndent
protected int rightChildIndent
要添加到leftChildIndent以确定将绘制单元格内容的位置的距离。
-
totalChildIndent
protected int totalChildIndent
将缩进的总距离。 leftChildIndent和rightChildIndent的总和。
-
preferredMinSize
protected Dimension preferredMinSize
最小首选尺寸。
-
lastSelectedRow
protected int lastSelectedRow
上次选择的行的索引。
-
tree
protected JTree tree
我们将要绘制的组件。
-
currentCellRenderer
protected transient TreeCellRenderer currentCellRenderer
用于进行实际单元格绘制的渲染器。
-
createdRenderer
protected boolean createdRenderer
如果此实例创建当前位于树中的渲染器,则设置为true。
-
cellEditor
protected transient TreeCellEditor cellEditor
树的编辑。
-
createdCellEditor
protected boolean createdCellEditor
如果此实例创建了当前位于树中的编辑器,则设置为true。
-
stopEditingInCompleteEditing
protected boolean stopEditingInCompleteEditing
编辑时设置为false,而shouldSelectCell()返回true表示在编辑之前应选择节点,用于completeEditing。
-
rendererPane
protected CellRendererPane rendererPane
用于绘制TreeCellRenderer。
-
preferredSize
protected Dimension preferredSize
完全显示所有节点所需的大小。
-
validCachedPreferredSize
protected boolean validCachedPreferredSize
preferredSize有效吗?
-
treeState
protected AbstractLayoutCache treeState
负责处理大小调整和扩展问题的对象。
-
largeModel
protected boolean largeModel
如果对largeModel进行优化,则为True。 不支持此功能的子类可能希望覆盖createLayoutCache以不返回FixedHeightLayoutCache实例。
-
nodeDimensions
protected AbstractLayoutCache.NodeDimensions nodeDimensions
负责告诉TreeState节点所需的大小。
-
treeModel
protected TreeModel treeModel
用于确定要显示的内容。
-
treeSelectionModel
protected TreeSelectionModel treeSelectionModel
模型保持选择。
-
depthOffset
protected int depthOffset
为了正确计算x位置,应该偏移多少深度。 这取决于根是否可见,以及根句柄是否可见。
-
editingComponent
protected Component editingComponent
编辑时,这将是正在进行实际编辑的组件。
-
editingPath
protected TreePath editingPath
正在编辑的路径。
-
editingRow
protected int editingRow
正在编辑的行。 仅当editingComponent不为null时才应引用。
-
editorHasDifferentSize
protected boolean editorHasDifferentSize
如果编辑器的大小与渲染器的大小不同,则设置为true。
-
-
方法详细信息
-
createUI
public static ComponentUI createUI(JComponent x)
构造一个BasicTreeUI的新实例。- 参数
-
x- 一个组件 - 结果
-
BasicTreeUI的新实例
-
getHashColor
protected Color getHashColor()
返回散列颜色。- 结果
- 哈希颜色
-
setHashColor
protected void setHashColor(Color color)
设置哈希颜色。- 参数
-
color- 哈希颜色
-
setLeftChildIndent
public void setLeftChildIndent(int newAmount)
设置左子缩进。- 参数
-
newAmount- 左侧儿童缩进
-
getLeftChildIndent
public int getLeftChildIndent()
返回左子缩进。- 结果
- 左边的孩子缩进
-
setRightChildIndent
public void setRightChildIndent(int newAmount)
设置正确的子缩进。- 参数
-
newAmount- 正确的儿童缩进
-
getRightChildIndent
public int getRightChildIndent()
返回正确的子缩进。- 结果
- 合适的孩子缩进
-
setExpandedIcon
public void setExpandedIcon(Icon newG)
设置展开的图标。- 参数
-
newG- 展开的图标
-
getExpandedIcon
public Icon getExpandedIcon()
返回展开的图标。- 结果
- 展开的图标
-
setCollapsedIcon
public void setCollapsedIcon(Icon newG)
设置折叠图标。- 参数
-
newG- 折叠图标
-
getCollapsedIcon
public Icon getCollapsedIcon()
返回折叠的图标。- 结果
- 折叠的图标
-
setLargeModel
protected void setLargeModel(boolean largeModel)
如有必要,更新componentListener。- 参数
-
largeModel- 新值
-
isLargeModel
protected boolean isLargeModel()
如果设置了大型模型,则返回true。- 结果
-
true如果设置了大型模型
-
setRowHeight
protected void setRowHeight(int rowHeight)
设置行高,将其转发到treeState。- 参数
-
rowHeight- 行高
-
getRowHeight
protected int getRowHeight()
返回行高。- 结果
- 行高
-
setCellRenderer
protected void setCellRenderer(TreeCellRenderer tcr)
将TreeCellRenderer设置为tcr。 这会调用updateRenderer。- 参数
-
tcr- 新值
-
getCellRenderer
protected TreeCellRenderer getCellRenderer()
返回currentCellRenderer,它将是树渲染器,或defaultCellRenderer,它们不是null。- 结果
-
TreeCellRenderer一个实例
-
setModel
protected void setModel(TreeModel model)
设置TreeModel。- 参数
-
model- 新值
-
getModel
protected TreeModel getModel()
返回树模型。- 结果
- 树模型
-
setRootVisible
protected void setRootVisible(boolean newValue)
将根设置为可见。- 参数
-
newValue- 新值
-
isRootVisible
protected boolean isRootVisible()
如果树根可见,则返回true。- 结果
-
true如果树根可见
-
setShowsRootHandles
protected void setShowsRootHandles(boolean newValue)
确定是否显示节点句柄。- 参数
-
newValue- 新值
-
getShowsRootHandles
protected boolean getShowsRootHandles()
如果要显示根句柄,则返回true。- 结果
-
true如果要显示根句柄
-
setCellEditor
protected void setCellEditor(TreeCellEditor editor)
设置单元格编辑器。- 参数
-
editor- 新的单元格编辑器
-
getCellEditor
protected TreeCellEditor getCellEditor()
返回TreeCellEditor的实例。- 结果
-
TreeCellEditor一个实例
-
setEditable
protected void setEditable(boolean newValue)
配置接收器允许或不允许编辑。- 参数
-
newValue- 新值
-
isEditable
protected boolean isEditable()
如果树可编辑,则返回true。- 结果
-
true树是否可编辑
-
setSelectionModel
protected void setSelectionModel(TreeSelectionModel newLSM)
重置选择模型。 适当的侦听器安装在模型上。- 参数
-
newLSM- 新的选择模型
-
getSelectionModel
protected TreeSelectionModel getSelectionModel()
返回树选择模型。- 结果
- 树选择模型
-
getPathBounds
public Rectangle getPathBounds(JTree tree, TreePath path)
返回包含将绘制路径中最后一项的标签部分的Rectangle。 如果路径中的任何组件当前有效,则返回null。- Specified by:
-
getPathBounds在TreeUI类中 - 参数
-
tree-JTree的path -
path- 标识节点的TreePath - 结果
-
Rectangle包含将绘制路径中最后一项的标签部分,如果路径中的任何组件当前有效,null。
-
getPathForRow
public TreePath getPathForRow(JTree tree, int row)
返回传入行的路径。 如果row不可见,则返回null。- Specified by:
-
getPathForRow在TreeUI类 - 参数
-
tree-JTree对象 -
row- 指定行的整数 - 结果
-
path为row或null如果row不可见
-
getRowForPath
public int getRowForPath(JTree tree, TreePath path)
返回路径中标识的最后一项可见的行。 如果路径中的任何元素当前不可见,则返回-1。- Specified by:
-
getRowForPath在课堂上TreeUI - 参数
-
tree-JTreeforpath -
path- 要查看的TreePath对象 - 结果
-
指定标识最后一项的行的整数,如果
path中的任何元素当前不可见,则返回-1
-
getRowCount
public int getRowCount(JTree tree)
返回正在显示的行数。- Specified by:
-
getRowCount在课堂上TreeUI - 参数
-
tree- 要为其计数行的JTree - 结果
- 一个整数,指定要显示的行数
-
getClosestPathForLocation
public TreePath getClosestPathForLocation(JTree tree, int x, int y)
返回最接近x,y的节点的路径。 如果当前没有任何内容可见,则返回null,否则它将始终返回有效路径。 如果你需要测试返回的对象是否正好在x,y,你应该获得返回路径的边界并测试x,y。- Specified by:
-
getClosestPathForLocation在课堂上TreeUI - 参数
-
tree-JTree对象 -
x- 一个整数,给出显示区域左边缘水平的像素数 -
y- 一个整数,给出显示区域顶部垂直的像素数,减去任何上边距 - 结果
-
TreePath节点最接近x,y或null如果当前没有任何可见
-
isEditing
public boolean isEditing(JTree tree)
如果正在编辑树,则返回true。 getEditingPath()可以返回正在编辑的项目。
-
stopEditing
public boolean stopEditing(JTree tree)
停止当前的编辑会话。 如果未编辑树,则无效。 如果编辑器允许编辑会话停止,则返回true。- Specified by:
-
stopEditing在课堂上TreeUI - 参数
-
tree-JTree对象 - 结果
- 如果编辑器允许编辑会话停止,则为true
-
cancelEditing
public void cancelEditing(JTree tree)
取消当前编辑会话。- Specified by:
-
cancelEditing在课堂上TreeUI - 参数
-
tree-JTree对象
-
startEditingAtPath
public void startEditingAtPath(JTree tree, TreePath path)
选择路径中的最后一项并尝试编辑它。 如果CellEditor不允许编辑所选项目,编辑将失败。- Specified by:
-
startEditingAtPath在TreeUI类 - 参数
-
tree- 正在编辑的JTree -
path- 要编辑的TreePath
-
getEditingPath
public TreePath getEditingPath(JTree tree)
返回正在编辑的元素的路径。- Specified by:
-
getEditingPath在TreeUI类 - 参数
-
tree- 要返回路径的JTree - 结果
-
一个
TreePath包含路径tree
-
prepareForUIInstall
protected void prepareForUIInstall()
在设置tree实例变量之后但在安装任何默认值/侦听器之前调用。
-
completeUIInstall
protected void completeUIInstall()
安装完所有默认值/侦听器后从installUI调用。
-
installDefaults
protected void installDefaults()
安装默认属性。
-
installListeners
protected void installListeners()
注册听众。
-
installKeyboardActions
protected void installKeyboardActions()
注册键盘操作。
-
installComponents
protected void installComponents()
Intall树的子组件,即渲染器窗格。
-
createNodeDimensions
protected AbstractLayoutCache.NodeDimensions createNodeDimensions()
创建NodeDimensions的实例,该实例能够确定树中给定节点的大小。- 结果
-
NodeDimensions一个实例
-
createPropertyChangeListener
protected PropertyChangeListener createPropertyChangeListener()
创建一个负责的监听器,根据树的更改方式更新UI。- 结果
-
PropertyChangeListener一个实例
-
createMouseListener
protected MouseListener createMouseListener()
创建负责根据鼠标事件更新选择的侦听器。- 结果
-
MouseListener一个实例
-
createFocusListener
protected FocusListener createFocusListener()
创建一个监听器,负责在丢失/获得焦点时更新显示。- 结果
-
FocusListener一个实例
-
createKeyListener
protected KeyListener createKeyListener()
创建负责从树中获取关键事件的侦听器。- 结果
-
KeyListener一个实例
-
createSelectionModelPropertyChangeListener
protected PropertyChangeListener createSelectionModelPropertyChangeListener()
创建负责从选择模型获取属性更改事件的侦听器。- 结果
-
PropertyChangeListener一个实例
-
createTreeSelectionListener
protected TreeSelectionListener createTreeSelectionListener()
创建基于选择更改方法更新显示的侦听器。- 结果
-
TreeSelectionListener一个实例
-
createCellEditorListener
protected CellEditorListener createCellEditorListener()
创建一个侦听器来处理当前编辑器中的事件。- 结果
-
CellEditorListener一个实例
-
createComponentListener
protected ComponentListener createComponentListener()
创建并返回一个新的ComponentHandler。 这用于大型模型,以在组件移动时将validCachedPreferredSize标记为无效。- 结果
-
ComponentListener一个实例
-
createTreeExpansionListener
protected TreeExpansionListener createTreeExpansionListener()
当节点扩展状态更改时,创建并返回负责更新treestate的对象。- 结果
-
TreeExpansionListener一个实例
-
createLayoutCache
protected AbstractLayoutCache createLayoutCache()
创建负责管理扩展内容的对象以及节点的大小。- 结果
- 负责管理扩展内容的对象
-
createCellRendererPane
protected CellRendererPane createCellRendererPane()
返回放置渲染器组件的渲染器窗格。- 结果
-
CellRendererPane一个实例
-
createDefaultCellEditor
protected TreeCellEditor createDefaultCellEditor()
创建默认单元格编辑器。- 结果
- 默认的单元格编辑器
-
createDefaultCellRenderer
protected TreeCellRenderer createDefaultCellRenderer()
返回用于对每个节点进行标记的默认单元格渲染器。- 结果
-
TreeCellRenderer一个实例
-
createTreeModelListener
protected TreeModelListener createTreeModelListener()
返回一个侦听器,可以在模型更改时更新树。- 结果
-
TreeModelListener一个实例。
-
prepareForUIUninstall
protected void prepareForUIUninstall()
在安装UI之前调用。
-
completeUIUninstall
protected void completeUIUninstall()
卸载UI。
-
uninstallDefaults
protected void uninstallDefaults()
卸载默认属性。
-
uninstallListeners
protected void uninstallListeners()
取消注册听众。
-
uninstallKeyboardActions
protected void uninstallKeyboardActions()
取消注册键盘操作。
-
uninstallComponents
protected void uninstallComponents()
卸载渲染器窗格。
-
getBaseline
public int getBaseline(JComponent c, int width, int height)
返回基线。- 重写:
-
getBaseline在类ComponentUI - 参数
-
c-JComponent正在申请基线 -
width- 获取基线的宽度 -
height- 获取基线的高度 - 结果
- 基线或值<0表示没有合理的基线
- 异常
-
NullPointerException- 如果c是null -
IllegalArgumentException- 如果宽度或高度<0 - 从以下版本开始:
- 1.6
- 另请参见:
-
JComponent.getBaseline(int, int)
-
getBaselineResizeBehavior
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
返回一个枚举,指示组件的基线如何随大小的变化而变化。- 重写:
-
getBaselineResizeBehavior在类ComponentUI - 参数
-
c-JComponent返回基线调整大小的行为 - 结果
- 一个枚举,指示基线随组件大小的变化而变化的方式
- 异常
-
NullPointerException- 如果c是null - 从以下版本开始:
- 1.6
- 另请参见:
-
JComponent.getBaseline(int, int)
-
isDropLine
protected boolean isDropLine(JTree.DropLocation loc)
告知DropLocation是否应由节点之间的线指示。 这适用于javax.swing.DropMode.INSERT和javax.swing.DropMode.ON_OR_INSERT丢弃模式。- 参数
-
loc- aDropLocation - 结果
-
true如果放置位置应显示为一条线 - 从以下版本开始:
- 1.7
-
paintDropLine
protected void paintDropLine(Graphics g)
画下线。- 参数
-
g-Graphics要绘制的对象 - 从以下版本开始:
- 1.7
-
getDropLineRect
protected Rectangle getDropLineRect(JTree.DropLocation loc)
返回下拉线的无限制框。- 参数
-
loc- aDropLocation - 结果
- 下拉线的边界框
- 从以下版本开始:
- 1.7
-
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。- 参数
-
g- 图形上下文 -
clipBounds- 剪裁的矩形 -
insets- 内insets -
bounds- 一个边界矩形 -
path- 树路径 -
row- 一排 -
isExpanded-true如果路径已展开 -
hasBeenExpanded-true如果路径已展开 -
isLeaf-true如果路径是叶子
-
paintVerticalPartOfLeg
protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)
涂抹腿部的垂直部分。 该接收器不应修改clipBounds,insets。- 参数
-
g- 图形上下文 -
clipBounds- 剪裁的矩形 -
insets- insets -
path- 树路径
-
paintExpandControl
protected void paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
绘制一行的展开(切换)部分。 接收方不应修改clipBounds或insets。- 参数
-
g- 图形上下文 -
clipBounds- 剪裁的矩形 -
insets- 内insets -
bounds- 一个边界矩形 -
path- 树路径 -
row- 一排 -
isExpanded-true如果路径已展开 -
hasBeenExpanded-true如果路径已展开 -
isLeaf-true如果行是叶子
-
paintRow
protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
绘制一行的渲染器部分。 接收方不应修改clipBounds或insets。- 参数
-
g- 图形上下文 -
clipBounds- 剪裁的矩形 -
insets- 内insets -
bounds- 一个边界矩形 -
path- 树路径 -
row- 一排 -
isExpanded-true如果路径已展开 -
hasBeenExpanded-true如果路径已展开 -
isLeaf-true如果路径是叶子
-
shouldPaintExpandControl
protected boolean shouldPaintExpandControl(TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
如果应为指定行绘制展开(切换)控件,则返回true。- 参数
-
path- 树路径 -
row- 一排 -
isExpanded-true如果路径已展开 -
hasBeenExpanded-true如果路径已展开 -
isLeaf-true如果行是叶子 - 结果
-
true是否应为指定行绘制展开(切换)控件
-
paintVerticalLine
protected void paintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom)
画一条垂直线。- 参数
-
g- 图形上下文 -
c- 组件 -
x- X坐标 -
top- Y1坐标 -
bottom- Y2坐标
-
paintHorizontalLine
protected void paintHorizontalLine(Graphics g, JComponent c, int y, int left, int right)
画一条水平线。- 参数
-
g- 图形上下文 -
c- 一个组件 -
y- Y坐标 -
left- X1坐标 -
right- X2坐标
-
getVerticalLegBuffer
protected int getVerticalLegBuffer()
节点之间的腿的垂直元素默认从父节点的底部开始。 这种方法使腿部开始低于此值。- 结果
- 垂直腿缓冲
-
getHorizontalLegBuffer
protected int getHorizontalLegBuffer()
默认情况下,节点之间的支路的水平元素从子节点的左侧开始。 这种方法在此之前使腿部结束。- 结果
- 水平腿缓冲
-
drawCentered
protected void drawCentered(Component c, Graphics graphics, Icon icon, int x, int y)
绘制以(x,y)为中心的icon。- 参数
-
c- 组件 -
graphics- 图形上下文 -
icon- 一个图标 -
x- X坐标 -
y- Y坐标
-
drawDashedHorizontalLine
protected void drawDashedHorizontalLine(Graphics g, int y, int x1, int x2)
画一条水平虚线。 假设x1<=x2。 如果x1大于x2,则该方法不提取任何内容。- 参数
-
g-实例Graphics -
y- Y坐标 -
x1- X1坐标 -
x2- X2坐标
-
drawDashedVerticalLine
protected void drawDashedVerticalLine(Graphics g, int x, int y1, int y2)
画一条垂直虚线。 假定为y1<=y2。 如果y1大于y2,则该方法不提取任何内容。- 参数
-
g-实例Graphics -
x- X坐标 -
y1- Y1坐标 -
y2- Y2坐标
-
getRowX
protected int getRowX(int row, int depth)返回沿x轴的位置,以呈现特定的行。 返回值不包括JTree上指定的任何Insets。 这不会检查行或深度的有效性,假设它是正确的,并且如果行或深度与树的行或深度不匹配,则不会抛出异常。- 参数
-
row- 要返回x位置的行 -
depth- 行的深度 - 结果
- 相当于缩进给定行的数量。
- 从以下版本开始:
- 1.5
-
updateLayoutCacheExpandedNodes
protected void updateLayoutCacheExpandedNodes()
使所有在JTree中扩展的节点在LayoutCache中扩展。 这将使用根路径调用updateExpandedDescendants。
-
updateExpandedDescendants
protected void updateExpandedDescendants(TreePath path)
通过从树中获取展开的后代并转发到树状态来更新path的所有后代的展开状态。- 参数
-
path- 树路径
-
getLastChildPath
protected TreePath getLastChildPath(TreePath parent)
返回最后一个子项parent的路径。- 参数
-
parent- 树路径 - 结果
-
最后一个孩子的路径
parent
-
updateDepthOffset
protected void updateDepthOffset()
更新每个深度应该偏移的程度。
-
updateCellEditor
protected void updateCellEditor()
根据我们所包含的JTree的可编辑性更新cellEditor。如果树是可编辑的但没有cellEditor,则将使用基本树。
-
updateRenderer
protected void updateRenderer()
当渲染器发生变化时,我们从树中传来消息。
-
configureLayoutCache
protected void configureLayoutCache()
根据我们提供外观的树重置TreeState实例。
-
updateSize
protected void updateSize()
将缓存的大小标记为无效,并使用treeDidChange向树发送消息。
-
updateCachedPreferredSize
protected void updateCachedPreferredSize()
更新preferredSize实例变量,该变量从getPreferredSize()返回。对于从左到右的方向,大小由当前的AbstractLayoutCache确定。 对于RTL方向,首选大小变为宽度减去最小x位置。
-
pathWasExpanded
protected void pathWasExpanded(TreePath path)
在VisibleTreeNode后从VisibleTreeNode消息。- 参数
-
path- 树路径
-
pathWasCollapsed
protected void pathWasCollapsed(TreePath path)
它崩溃后从VisibleTreeNode消息。- 参数
-
path- 树路径
-
ensureRowsAreVisible
protected void ensureRowsAreVisible(int beginRow, int endRow)确保beginRow至endRow标识的行可见。- 参数
-
beginRow- 开始行 -
endRow- 结束行
-
setPreferredMinSize
public void setPreferredMinSize(Dimension newSize)
设置首选最小大小。- 参数
-
newSize- 新的首选大小
-
getPreferredMinSize
public Dimension getPreferredMinSize()
返回最小首选大小。- 结果
- 最小首选尺寸
-
getPreferredSize
public Dimension getPreferredSize(JComponent c)
返回正确显示树的首选大小,这是getPreferredSize(c, true)的封面方法。- 重写:
-
getPreferredSize在类ComponentUI - 参数
-
c- 一个组件 - 结果
- 表示组件中树的首选大小
- 另请参见:
-
JComponent.getPreferredSize(),LayoutManager.preferredLayoutSize(java.awt.Container)
-
getPreferredSize
public Dimension getPreferredSize(JComponent c, boolean checkConsistency)
返回表示c中树的首选大小。 如果checkConsistency为true则首先truecheckConsistency消息。- 参数
-
c- 一个组件 -
checkConsistency- 如果检查true一致性 - 结果
- 表示组件中树的首选大小
-
getMinimumSize
public Dimension getMinimumSize(JComponent c)
返回此组件的最小大小。 这将是最小首选大小或0,0。- 重写:
-
getMinimumSize在类ComponentUI - 参数
-
c- 正在查询其最小大小的组件; 此参数通常被忽略,但如果UI对象是无状态的并且由多个组件共享,则可以使用此参数 - 结果
-
Dimension对象或null - 另请参见:
-
JComponent.getMinimumSize(),LayoutManager.minimumLayoutSize(java.awt.Container),ComponentUI.getPreferredSize(javax.swing.JComponent)
-
getMaximumSize
public Dimension getMaximumSize(JComponent c)
返回此组件的最大大小,如果实例当前位于JTree中,则该大小将是首选大小,或0,0。- 重写:
-
getMaximumSize在类ComponentUI - 参数
-
c- 正在查询其最大大小的组件; 此参数通常被忽略,但如果UI对象是无状态的并且由多个组件共享,则可以使用此参数 - 结果
-
Dimension对象或null - 另请参见:
-
JComponent.getMaximumSize(),LayoutManager2.maximumLayoutSize(java.awt.Container)
-
completeEditing
protected void completeEditing()
用于停止编辑会话的消息。 如果接收器提供的外观和感觉从getInvokesStopCellEditing返回true,则将在当前编辑器上调用stopCellEditing。 然后,completeEditing将显示false,true,false消息,以取消任何延迟编辑。
-
completeEditing
protected void completeEditing(boolean messageStop, boolean messageCancel, boolean messageTree)停止编辑会话。 如果messageStop为true编辑器中传递消息与stopEditing,如果messageCancel为true编辑器中传递消息与cancelEditing。 如果messageTree是true向treeModel消息valueForPathChanged。- 参数
-
messageStop- 要停止编辑的消息 -
messageCancel- 取消编辑的消息 -
messageTree- 树的消息
-
startEditing
protected boolean startEditing(TreePath path, MouseEvent event)
如果有cellEditor和shouldSelectCell返回true将开始编辑节点。这假定路径有效且可见。
- 参数
-
path- 树路径 -
event- 鼠标事件 - 结果
-
true如果编辑成功
-
checkForClickInExpandControl
protected void checkForClickInExpandControl(TreePath path, int mouseX, int mouseY)
如果mouseX和mouseY都在的展开/折叠区域row,这将切换行。- 参数
-
path- 树路径 -
mouseX- X坐标 -
mouseY- Y坐标
-
isLocationInExpandControl
protected boolean isLocationInExpandControl(TreePath path, int mouseX, int mouseY)
返回true如果mouseX和mouseY下降,用于展开/折叠节点和节点的行的区域row不代表叶子。- 参数
-
path- 树路径 -
mouseX- X坐标 -
mouseY- Y坐标 - 结果
-
true如果鼠标光标落在用于展开/折叠节点且该节点不是叶子的行区域中。
-
handleExpandControlClick
protected void handleExpandControlClick(TreePath path, int mouseX, int mouseY)
当用户单击特定行时发送消息,这将调用toggleExpandState。- 参数
-
path- 树路径 -
mouseX- X坐标 -
mouseY- Y坐标
-
toggleExpandState
protected void toggleExpandState(TreePath path)
如果未展开,则展开路径;如果展开,则展开行。 如果扩张的路径和JTree上扩大卷轴,ensureRowsAreVisible被调用,以尽可能多的孩子滚动到尽可能可见(试图滚动到路径的最后一个可见的后代)。- 参数
-
path- 树路径
-
isToggleSelectionEvent
protected boolean isToggleSelectionEvent(MouseEvent event)
返回true表示节点上的鼠标事件应该仅切换鼠标true的选择。- 参数
-
event- 鼠标事件 - 结果
-
true如果节点上的鼠标事件应切换选择
-
isMultiSelectEvent
protected boolean isMultiSelectEvent(MouseEvent event)
返回true表示节点上的鼠标事件应从锚点中选择。- 参数
-
event- 鼠标事件 - 结果
-
true如果节点上的鼠标事件应从锚点中选择
-
isToggleEvent
protected boolean isToggleEvent(MouseEvent event)
返回true表示应根据事件切换鼠标下的行。 这是在checkForClickInExpandControl之后调用的,这意味着该位置不在扩展(切换)控件中。- 参数
-
event- 鼠标事件 - 结果
-
true如果应该切换鼠标下的行
-
selectPathForEvent
protected void selectPathForEvent(TreePath path, MouseEvent event)
消息传递基于特定行的MouseEvent更新选择。 如果事件是切换选择事件,则选择或取消选择该行。 如果事件标识多选事件,则从锚点更新选择。 否则,将选择该行,如果事件指定了切换事件,则行将展开/折叠。- 参数
-
path- 所选路径 -
event- 鼠标事件
-
isLeaf
protected boolean isLeaf(int row)
返回true如果在节点row是叶。- 参数
-
row- 一排 - 结果
-
true如果在节点row是叶
-
updateLeadSelectionRow
protected void updateLeadSelectionRow()
更新选择的前导行。- 从以下版本开始:
- 1.7
-
getLeadSelectionRow
protected int getLeadSelectionRow()
返回选择的前导行。- 结果
- 选择引导行
- 从以下版本开始:
- 1.7
-
-