MetalTreeUI, SynthTreeUI
public class BasicTreeUI extends TreeUI
| Modifier and Type | Class | Description | 
|---|---|---|
| class  | BasicTreeUI.CellEditorHandler | Listener responsible for getting cell editing events and updating the tree accordingly. | 
| class  | BasicTreeUI.ComponentHandler | Updates the preferred size when scrolling (if necessary). | 
| class  | BasicTreeUI.FocusHandler | Repaints the lead selection row when focus is lost/gained. | 
| class  | BasicTreeUI.KeyHandler | This is used to get multiple key down events to appropriately generate events. | 
| class  | BasicTreeUI.MouseHandler | TreeMouseListener is responsible for updating the selection based on mouse events. | 
| class  | BasicTreeUI.MouseInputHandler | MouseInputHandler handles passing all mouse events, including mouse motion events, until the mouse is released to the destination it is constructed with. | 
| class  | BasicTreeUI.NodeDimensionsHandler | Class responsible for getting size of node, method is forwarded to BasicTreeUI method. | 
| class  | BasicTreeUI.PropertyChangeHandler | PropertyChangeListener for the tree. | 
| class  | BasicTreeUI.SelectionModelPropertyChangeHandler | Listener on the TreeSelectionModel, resets the row selection if any of the properties of the model change. | 
| class  | BasicTreeUI.TreeCancelEditingAction | ActionListener that invokes cancelEditing when action performed. | 
| class  | BasicTreeUI.TreeExpansionHandler | Updates the TreeState in response to nodes expanding/collapsing. | 
| class  | BasicTreeUI.TreeHomeAction | TreeHomeAction is used to handle end/home actions. | 
| class  | BasicTreeUI.TreeIncrementAction | TreeIncrementAction is used to handle up/down actions. | 
| class  | BasicTreeUI.TreeModelHandler | Forwards all TreeModel events to the TreeState. | 
| class  | BasicTreeUI.TreePageAction | TreePageAction handles page up and page down events. | 
| class  | BasicTreeUI.TreeSelectionHandler | Listens for changes in the selection model and updates the display accordingly. | 
| class  | BasicTreeUI.TreeToggleAction | For the first selected row expandedness will be toggled. | 
| class  | BasicTreeUI.TreeTraverseAction | TreeTraverseActionis the action used for left/right keys. | 
| Modifier and Type | Field | Description | 
|---|---|---|
| protected TreeCellEditor | cellEditor | Editor for the tree. | 
| protected Icon | collapsedIcon | The collapsed icon. | 
| protected boolean | createdCellEditor | Set to true if editor that is currently in the tree was created by this instance. | 
| protected boolean | createdRenderer | Set to true if the renderer that is currently in the tree was created by this instance. | 
| protected TreeCellRenderer | currentCellRenderer | Renderer that is being used to do the actual cell drawing. | 
| protected int | depthOffset | How much the depth should be offset to properly calculate x locations. | 
| protected Hashtable | drawingCache | Used for minimizing the drawing of vertical lines. | 
| protected Component | editingComponent | When editing, this will be the Component that is doing the actual editing. | 
| protected TreePath | editingPath | Path that is being edited. | 
| protected int | editingRow | Row that is being edited. | 
| protected boolean | editorHasDifferentSize | Set to true if the editor has a different size than the renderer. | 
| protected Icon | expandedIcon | The expanded icon. | 
| protected boolean | largeModel | True if doing optimizations for a largeModel. | 
| protected int | lastSelectedRow | Index of the row that was last selected. | 
| protected int | leftChildIndent | Distance between left margin and where vertical dashes will be drawn. | 
| protected AbstractLayoutCache.NodeDimensions | nodeDimensions | Responsible for telling the TreeState the size needed for a node. | 
| protected Dimension | preferredMinSize | Minimum preferred size. | 
| protected Dimension | preferredSize | Size needed to completely display all the nodes. | 
| protected CellRendererPane | rendererPane | Used to paint the TreeCellRenderer. | 
| protected int | rightChildIndent | Distance to add to leftChildIndent to determine where cell contents will be drawn. | 
| protected boolean | stopEditingInCompleteEditing | Set to false when editing and shouldSelectCell() returns true meaning the node should be selected before editing, used in completeEditing. | 
| protected int | totalChildIndent | Total distance that will be indented. | 
| protected JTree | tree | Component that we're going to be drawing into. | 
| protected TreeModel | treeModel | Used to determine what to display. | 
| protected TreeSelectionModel | treeSelectionModel | Model maintaining the selection. | 
| protected AbstractLayoutCache | treeState | Object responsible for handling sizing and expanded issues. | 
| protected boolean | validCachedPreferredSize | Is the preferredSize valid? | 
| Constructor | Description | 
|---|---|
| BasicTreeUI() | Constructs a new instance of  BasicTreeUI. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| void | cancelEditing | Cancels the current editing session. | 
| protected void | checkForClickInExpandControl | If the  mouseXandmouseYare in the expand/collapse region of therow, this will toggle the row. | 
| protected void | completeEditing() | Messages to stop the editing session. | 
| protected void | completeEditing | Stops the editing session. | 
| protected void | completeUIInstall() | Invoked from installUI after all the defaults/listeners have been installed. | 
| protected void | completeUIUninstall() | Uninstalls UI. | 
| protected void | configureLayoutCache() | Resets the TreeState instance based on the tree we're providing the look and feel for. | 
| protected CellEditorListener | createCellEditorListener() | Creates a listener to handle events from the current editor. | 
| protected CellRendererPane | createCellRendererPane() | Returns the renderer pane that renderer components are placed in. | 
| protected ComponentListener | createComponentListener() | Creates and returns a new ComponentHandler. | 
| protected TreeCellEditor | createDefaultCellEditor() | Creates a default cell editor. | 
| protected TreeCellRenderer | createDefaultCellRenderer() | Returns the default cell renderer that is used to do the stamping of each node. | 
| protected FocusListener | createFocusListener() | Creates a listener that is responsible for updating the display when focus is lost/gained. | 
| protected KeyListener | createKeyListener() | Creates the listener responsible for getting key events from the tree. | 
| protected AbstractLayoutCache | createLayoutCache() | Creates the object responsible for managing what is expanded, as well as the size of nodes. | 
| protected MouseListener | createMouseListener() | Creates the listener responsible for updating the selection based on mouse events. | 
| protected AbstractLayoutCache.NodeDimensions | createNodeDimensions() | Creates an instance of  NodeDimensionsthat is able to determine the size of a given node in the tree. | 
| protected PropertyChangeListener | createPropertyChangeListener() | Creates a listener that is responsible that updates the UI based on how the tree changes. | 
| protected PropertyChangeListener | createSelectionModelPropertyChangeListener() | Creates the listener responsible for getting property change events from the selection model. | 
| protected TreeExpansionListener | createTreeExpansionListener() | Creates and returns the object responsible for updating the treestate when nodes expanded state changes. | 
| protected TreeModelListener | createTreeModelListener() | Returns a listener that can update the tree when the model changes. | 
| protected TreeSelectionListener | createTreeSelectionListener() | Creates the listener that updates the display based on selection change methods. | 
| static ComponentUI | createUI | Constructs a new instance of  BasicTreeUI. | 
| protected void | drawCentered | Draws the  iconcentered at (x,y). | 
| protected void | drawDashedHorizontalLine | Draws a horizontal dashed line. | 
| protected void | drawDashedVerticalLine | Draws a vertical dashed line. | 
| protected void | ensureRowsAreVisible | Ensures that the rows identified by  beginRowthroughendRoware visible. | 
| int | getBaseline | Returns the baseline. | 
| Component.BaselineResizeBehavior | getBaselineResizeBehavior | Returns an enum indicating how the baseline of the component changes as the size changes. | 
| protected TreeCellEditor | getCellEditor() | Returns the editor used to edit entries in the drawn tree component, or  nullif the tree cannot be edited. | 
| protected TreeCellRenderer | getCellRenderer() | Returns the current instance of the  TreeCellRendererthat is rendering each cell. | 
| TreePath | getClosestPathForLocation | Returns the path to the node that is closest to x,y. | 
| Icon | getCollapsedIcon() | Returns the collapsed icon. | 
| protected Rectangle | getDropLineRect | Returns a unbounding box for the drop line. | 
| TreePath | getEditingPath | Returns the path to the element that is being edited. | 
| Icon | getExpandedIcon() | Returns the expanded icon. | 
| protected Color | getHashColor() | Returns the hash color. | 
| protected int | getHorizontalLegBuffer() | The horizontal element of legs between nodes starts at the right of the left-hand side of the child node by default. | 
| protected TreePath | getLastChildPath | Returns a path to the last child of  parent. | 
| protected int | getLeadSelectionRow() | Returns the lead row of the selection. | 
| int | getLeftChildIndent() | Returns the left child indent. | 
| Dimension | getMaximumSize | Returns the maximum size for this component, which will be the preferred size if the instance is currently in a JTree, or 0, 0. | 
| Dimension | getMinimumSize | Returns the minimum size for this component. | 
| protected TreeModel | getModel() | Returns the tree model. | 
| Rectangle | getPathBounds | Returns the Rectangle enclosing the label portion that the last item in path will be drawn into. | 
| TreePath | getPathForRow | Returns the path for passed in row. | 
| Dimension | getPreferredMinSize() | Returns the minimum preferred size. | 
| Dimension | getPreferredSize | Returns the preferred size to properly display the tree, this is a cover method for  getPreferredSize(c, true). | 
| Dimension | getPreferredSize | Returns the preferred size to represent the tree in c. | 
| int | getRightChildIndent() | Returns the right child indent. | 
| int | getRowCount | Returns the number of rows that are being displayed. | 
| int | getRowForPath | Returns the row that the last item identified in path is visible at. | 
| protected int | getRowHeight() | Returns the height of each row in the drawn tree component. | 
| protected int | getRowX | Returns the location, along the x-axis, to render a particular row at. | 
| protected TreeSelectionModel | getSelectionModel() | Returns the current instance of the  TreeSelectionModelwhich is the model for selections. | 
| protected boolean | getShowsRootHandles() | Returns  trueif the root handles are to be displayed. | 
| protected int | getVerticalLegBuffer() | The vertical element of legs between nodes starts at the bottom of the parent node by default. | 
| protected void | handleExpandControlClick | Messaged when the user clicks the particular row, this invokes  toggleExpandState. | 
| protected void | installComponents() | Intalls the subcomponents of the tree, which is the renderer pane. | 
| protected void | installDefaults() | Installs default properties. | 
| protected void | installKeyboardActions() | Registers keyboard actions. | 
| protected void | installListeners() | Registers listeners. | 
| protected boolean | isDropLine | Tells if a  DropLocationshould be indicated by a line between nodes. | 
| protected boolean | isEditable() | Returns whether the drawn tree component should be enabled for editing. | 
| boolean | isEditing | Returns true if the tree is being edited. | 
| protected boolean | isLargeModel() | Returns  trueif large model is set. | 
| protected boolean | isLeaf | Returns  trueif the node atrowis a leaf. | 
| protected boolean | isLocationInExpandControl | Returns  trueifmouseXandmouseYfall in the area of row that is used to expand/collapse the node and the node atrowdoes not represent a leaf. | 
| protected boolean | isMultiSelectEvent | Returning  truesignifies a mouse event on the node should select from the anchor point. | 
| protected boolean | isRootVisible() | Returns whether the root node of the drawn tree component should be displayed. | 
| protected boolean | isToggleEvent | Returning  trueindicates the row under the mouse should be toggled based on the event. | 
| protected boolean | isToggleSelectionEvent | Returning  truesignifies a mouse event on the node should toggle the selection of only the row under mouse. | 
| protected void | paintDropLine | Paints the drop line. | 
| protected void | paintExpandControl | Paints the expand (toggle) part of a row. | 
| protected void | paintHorizontalLine | Paints a horizontal line. | 
| protected void | paintHorizontalPartOfLeg | Paints the horizontal part of the leg. | 
| protected void | paintRow | Paints the renderer part of a row. | 
| protected void | paintVerticalLine | Paints a vertical line. | 
| protected void | paintVerticalPartOfLeg | Paints the vertical part of the leg. | 
| protected void | pathWasCollapsed | Messaged from the  VisibleTreeNodeafter it has collapsed. | 
| protected void | pathWasExpanded | Messaged from the  VisibleTreeNodeafter it has been expanded. | 
| protected void | prepareForUIInstall() | Invoked after the  treeinstance variable has been set, but before any defaults/listeners have been installed. | 
| protected void | prepareForUIUninstall() | Invoked before uninstallation of UI. | 
| protected void | selectPathForEvent | Messaged to update the selection based on a  MouseEventover a particular row. | 
| protected void | setCellEditor | Sets the cell editor. | 
| protected void | setCellRenderer | Sets the  TreeCellRenderertotcr. | 
| void | setCollapsedIcon | Sets the collapsed icon. | 
| protected void | setEditable | Configures the receiver to allow, or not allow, editing. | 
| void | setExpandedIcon | Sets the expanded icon. | 
| protected void | setHashColor | Sets the hash color. | 
| protected void | setLargeModel | Sets the  largeModel. | 
| void | setLeftChildIndent | Sets the left child indent. | 
| protected void | setModel | Sets the  TreeModel. | 
| void | setPreferredMinSize | Sets the preferred minimum size. | 
| void | setRightChildIndent | Sets the right child indent. | 
| protected void | setRootVisible | Sets the root to being visible. | 
| protected void | setRowHeight | Sets the row height, this is forwarded to the treeState. | 
| protected void | setSelectionModel | Resets the selection model. | 
| protected void | setShowsRootHandles | Determines whether the node handles are to be displayed. | 
| protected boolean | shouldPaintExpandControl | Returns  trueif the expand (toggle) control should be drawn for the specified row. | 
| protected boolean | startEditing | Will start editing for node if there is a  cellEditorandshouldSelectCellreturnstrue. | 
| void | startEditingAtPath | Selects the last item in path and tries to edit it. | 
| boolean | stopEditing | Stops the current editing session. | 
| protected void | toggleExpandState | Expands path if it is not expanded, or collapses row if it is expanded. | 
| protected void | uninstallComponents() | Uninstalls the renderer pane. | 
| protected void | uninstallDefaults() | Uninstalls default properties. | 
| protected void | uninstallKeyboardActions() | Unregisters keyboard actions. | 
| protected void | uninstallListeners() | Unregisters listeners. | 
| protected void | updateCachedPreferredSize() | Updates the  preferredSizeinstance variable, which is returned fromgetPreferredSize(). | 
| protected void | updateCellEditor() | Updates the cellEditor based on the editability of the JTree that we're contained in. | 
| protected void | updateDepthOffset() | Updates how much each depth should be offset by. | 
| protected void | updateExpandedDescendants | Updates the expanded state of all the descendants of  pathby getting the expanded descendants from the tree and forwarding to the tree state. | 
| protected void | updateLayoutCacheExpandedNodes() | Makes all the nodes that are expanded in JTree expanded in LayoutCache. | 
| protected void | updateLeadSelectionRow() | Updates the lead row of the selection. | 
| protected void | updateRenderer() | Messaged from the tree we're in when the renderer has changed. | 
| protected void | updateSize() | Marks the cached size as being invalid, and messages the tree with  treeDidChange. | 
contains, getAccessibleChild, getAccessibleChildrenCount, installUI, paint, uninstallUI, update
protected transient Icon collapsedIcon
protected transient Icon expandedIcon
protected int leftChildIndent
protected int rightChildIndent
protected int totalChildIndent
protected Dimension preferredMinSize
protected int lastSelectedRow
protected JTree tree
protected transient TreeCellRenderer currentCellRenderer
protected boolean createdRenderer
protected transient TreeCellEditor cellEditor
protected boolean createdCellEditor
protected boolean stopEditingInCompleteEditing
protected CellRendererPane rendererPane
protected Dimension preferredSize
protected boolean validCachedPreferredSize
protected AbstractLayoutCache treeState
protected Hashtable<TreePath,Boolean> drawingCache
protected boolean largeModel
protected AbstractLayoutCache.NodeDimensions nodeDimensions
protected TreeModel treeModel
protected TreeSelectionModel treeSelectionModel
protected int depthOffset
protected Component editingComponent
protected TreePath editingPath
protected int editingRow
protected boolean editorHasDifferentSize
public BasicTreeUI()
BasicTreeUI.public static ComponentUI createUI(JComponent x)
BasicTreeUI.x - a componentBasicTreeUI
protected Color getHashColor()
protected void setHashColor(Color color)
color - the hash colorpublic void setLeftChildIndent(int newAmount)
newAmount - the left child indentpublic int getLeftChildIndent()
public void setRightChildIndent(int newAmount)
newAmount - the right child indentpublic int getRightChildIndent()
public void setExpandedIcon(Icon newG)
newG - the expanded iconpublic Icon getExpandedIcon()
public void setCollapsedIcon(Icon newG)
newG - the collapsed iconpublic Icon getCollapsedIcon()
protected void setLargeModel(boolean largeModel)
largeModel. Called when the largeModel property is changed in the drawn tree component.largeModel - the new value of the largeModel propertyprotected boolean isLargeModel()
true if large model is set.true if large model is setprotected void setRowHeight(int rowHeight)
rowHeight property is changed in the drawn tree component.rowHeight - the new value of the rowHeight propertyprotected int getRowHeight()
protected void setCellRenderer(TreeCellRenderer tcr)
TreeCellRenderer to tcr. This invokes updateRenderer. Called when the cellRenderer property is changed in the drawn tree component.tcr - the new value of the cellRenderer propertyprotected TreeCellRenderer getCellRenderer()
TreeCellRenderer that is rendering each cell.TreeCellRenderer instanceprotected void setModel(TreeModel model)
TreeModel.model - the new valueprotected TreeModel getModel()
protected void setRootVisible(boolean newValue)
rootVisible property is changed in the drawn tree component.newValue - the new value of the rootVisible propertyprotected boolean isRootVisible()
true if the root node of the tree is displayedprotected void setShowsRootHandles(boolean newValue)
showsRootHandles property is changed in the drawn tree component.newValue - the new value of the showsRootHandles propertyprotected boolean getShowsRootHandles()
true if the root handles are to be displayed.true if the root handles are to be displayedprotected void setCellEditor(TreeCellEditor editor)
cellEditor property is changed in the drawn tree component.editor - the new value of the cellEditor propertyprotected TreeCellEditor getCellEditor()
null if the tree cannot be edited.TreeCellEditor instance, or null
protected void setEditable(boolean newValue)
editable property is changed in the drawn tree component.newValue - the new value of the editable propertyprotected boolean isEditable()
true if the tree is editableprotected void setSelectionModel(TreeSelectionModel newLSM)
selectionModel property is changed in the drawn tree component.newLSM - the new value of the selectionModel propertyprotected TreeSelectionModel getSelectionModel()
TreeSelectionModel which is the model for selections.TreeSelectionModel instancepublic Rectangle getPathBounds(JTree tree, TreePath path)
getPathBounds in class TreeUI
tree - the JTree for path
path - the TreePath identifying the nodeRectangle enclosing the label portion that the last item in path will be drawn into, null if any component in path is currently valid.public TreePath getPathForRow(JTree tree, int row)
getPathForRow in class TreeUI
tree - a JTree objectrow - an integer specifying a rowpath for row or null if row is not visiblepublic int getRowForPath(JTree tree, TreePath path)
getRowForPath in class TreeUI
tree - the JTree for path
path - the TreePath object to look inpath are not currently visiblepublic int getRowCount(JTree tree)
getRowCount in class TreeUI
tree - the JTree for which to count rowspublic TreePath getClosestPathForLocation(JTree tree, int x, int y)
getClosestPathForLocation in class TreeUI
tree - a JTree objectx - an integer giving the number of pixels horizontally from the left edge of the display areay - an integer giving the number of pixels vertically from the top of the display area, minus any top marginTreePath node closest to x,y or null if there is nothing currently visiblepublic boolean isEditing(JTree tree)
public boolean stopEditing(JTree tree)
stopEditing in class TreeUI
tree - a JTree objectpublic void cancelEditing(JTree tree)
cancelEditing in class TreeUI
tree - a JTree objectpublic void startEditingAtPath(JTree tree, TreePath path)
startEditingAtPath in class TreeUI
tree - the JTree being editedpath - the TreePath to be editedpublic TreePath getEditingPath(JTree tree)
getEditingPath in class TreeUI
tree - the JTree for which to return a pathTreePath containing the path to tree
protected void prepareForUIInstall()
tree instance variable has been set, but before any defaults/listeners have been installed.protected void completeUIInstall()
protected void installDefaults()
protected void installListeners()
protected void installKeyboardActions()
protected void installComponents()
protected AbstractLayoutCache.NodeDimensions createNodeDimensions()
NodeDimensions that is able to determine the size of a given node in the tree.NodeDimensions
protected PropertyChangeListener createPropertyChangeListener()
PropertyChangeListener
protected MouseListener createMouseListener()
MouseListener
protected FocusListener createFocusListener()
FocusListener
protected KeyListener createKeyListener()
KeyListener
protected PropertyChangeListener createSelectionModelPropertyChangeListener()
PropertyChangeListener
protected TreeSelectionListener createTreeSelectionListener()
TreeSelectionListener
protected CellEditorListener createCellEditorListener()
CellEditorListener
protected ComponentListener createComponentListener()
ComponentListener
protected TreeExpansionListener createTreeExpansionListener()
TreeExpansionListener
protected AbstractLayoutCache createLayoutCache()
protected CellRendererPane createCellRendererPane()
CellRendererPane
protected TreeCellEditor createDefaultCellEditor()
protected TreeCellRenderer createDefaultCellRenderer()
TreeCellRenderer
protected TreeModelListener createTreeModelListener()
TreeModelListener.protected void prepareForUIUninstall()
protected void completeUIUninstall()
protected void uninstallDefaults()
protected void uninstallListeners()
protected void uninstallKeyboardActions()
protected void uninstallComponents()
public int getBaseline(JComponent c, int width, int height)
getBaseline in class ComponentUI
c - JComponent baseline is being requested forwidth - the width to get the baseline forheight - the height to get the baseline forNullPointerException - if c is null
IllegalArgumentException - if width or height is < 0public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior in class ComponentUI
c - JComponent to return baseline resize behavior forNullPointerException - if c is null
protected boolean isDropLine(JTree.DropLocation loc)
DropLocation should be indicated by a line between nodes. This is meant for javax.swing.DropMode.INSERT and javax.swing.DropMode.ON_OR_INSERT drop modes.loc - a DropLocation
true if the drop location should be shown as a lineprotected void paintDropLine(Graphics g)
g - Graphics object to draw onprotected Rectangle getDropLineRect(JTree.DropLocation loc)
loc - a DropLocation
protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
clipBounds, or insets. NOTE: parentRow can be -1 if the root is not visible.
g - a graphics contextclipBounds - a clipped rectangleinsets - insetsbounds - a bounding rectanglepath - a tree pathrow - a rowisExpanded - true if the path is expandedhasBeenExpanded - true if the path has been expandedisLeaf - true if the path is leafprotected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)
clipBounds, insets.g - a graphics contextclipBounds - a clipped rectangleinsets - insetspath - a tree pathprotected void paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
clipBounds, or insets.g - a graphics contextclipBounds - a clipped rectangleinsets - insetsbounds - a bounding rectanglepath - a tree pathrow - a rowisExpanded - true if the path is expandedhasBeenExpanded - true if the path has been expandedisLeaf - true if the row is leafprotected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
clipBounds, or insets.g - a graphics contextclipBounds - a clipped rectangleinsets - insetsbounds - a bounding rectanglepath - a tree pathrow - a rowisExpanded - true if the path is expandedhasBeenExpanded - true if the path has been expandedisLeaf - true if the path is leafprotected boolean shouldPaintExpandControl(TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
true if the expand (toggle) control should be drawn for the specified row.path - a tree pathrow - a rowisExpanded - true if the path is expandedhasBeenExpanded - true if the path has been expandedisLeaf - true if the row is leaftrue if the expand (toggle) control should be drawn for the specified rowprotected void paintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom)
g - a graphics contextc - a componentx - an X coordinatetop - an Y1 coordinatebottom - an Y2 coordinateprotected void paintHorizontalLine(Graphics g, JComponent c, int y, int left, int right)
g - a graphics contextc - a componenty - an Y coordinateleft - an X1 coordinateright - an X2 coordinateprotected int getVerticalLegBuffer()
protected int getHorizontalLegBuffer()
protected void drawCentered(Component c, Graphics graphics, Icon icon, int x, int y)
icon centered at (x,y).c - a componentgraphics - a graphics contexticon - an iconx - an X coordinatey - an Y coordinateprotected void drawDashedHorizontalLine(Graphics g, int y, int x1, int x2)
x1 <= x2. If x1 is greater than x2, the method draws nothing.g - an instance of Graphics
y - an Y coordinatex1 - an X1 coordinatex2 - an X2 coordinateprotected void drawDashedVerticalLine(Graphics g, int x, int y1, int y2)
y1 <= y2. If y1 is greater than y2, the method draws nothing.g - an instance of Graphics
x - an X coordinatey1 - an Y1 coordinatey2 - an Y2 coordinateprotected int getRowX(int row, int depth)
row - Row to return x location fordepth - Depth of the rowprotected void updateLayoutCacheExpandedNodes()
protected void updateExpandedDescendants(TreePath path)
path by getting the expanded descendants from the tree and forwarding to the tree state.path - a tree pathprotected TreePath getLastChildPath(TreePath parent)
parent.parent - a tree pathparent
protected void updateDepthOffset()
protected void updateCellEditor()
protected void updateRenderer()
protected void configureLayoutCache()
protected void updateSize()
treeDidChange.protected void updateCachedPreferredSize()
preferredSize instance variable, which is returned from getPreferredSize().For left to right orientations, the size is determined from the current AbstractLayoutCache. For RTL orientations, the preferred size becomes the width minus the minimum x position.
protected void pathWasExpanded(TreePath path)
VisibleTreeNode after it has been expanded.path - a tree pathprotected void pathWasCollapsed(TreePath path)
VisibleTreeNode after it has collapsed.path - a tree pathprotected void ensureRowsAreVisible(int beginRow, int endRow)
beginRow through endRow are visible.beginRow - the begin rowendRow - the end rowpublic void setPreferredMinSize(Dimension newSize)
newSize - the new preferred sizepublic Dimension getPreferredMinSize()
public Dimension getPreferredSize(JComponent c)
getPreferredSize(c, true).getPreferredSize in class ComponentUI
c - a componentpublic Dimension getPreferredSize(JComponent c, boolean checkConsistency)
true checkConsistency is messaged first.c - a componentcheckConsistency - if true consistency is checkedpublic Dimension getMinimumSize(JComponent c)
getMinimumSize in class ComponentUI
c - the component whose minimum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentsDimension object or null
public Dimension getMaximumSize(JComponent c)
getMaximumSize in class ComponentUI
c - the component whose maximum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentsDimension object or null
protected void completeEditing()
getInvokesStopCellEditing, stopCellEditing will invoked on the current editor. Then completeEditing will be messaged with false, true, false to cancel any lingering editing.protected void completeEditing(boolean messageStop, boolean messageCancel, boolean messageTree)
messageStop is true the editor is messaged with stopEditing, if messageCancel is true the editor is messaged with cancelEditing. If messageTree is true the treeModel is messaged with valueForPathChanged.messageStop - message to stop editingmessageCancel - message to cancel editingmessageTree - message to treeprotected boolean startEditing(TreePath path, MouseEvent event)
cellEditor and shouldSelectCell returns true.This assumes that path is valid and visible.
path - a tree pathevent - a mouse eventtrue if the editing is successfulprotected void checkForClickInExpandControl(TreePath path, int mouseX, int mouseY)
mouseX and mouseY are in the expand/collapse region of the row, this will toggle the row.path - a tree pathmouseX - an X coordinatemouseY - an Y coordinateprotected boolean isLocationInExpandControl(TreePath path, int mouseX, int mouseY)
true if mouseX and mouseY fall in the area of row that is used to expand/collapse the node and the node at row does not represent a leaf.path - a tree pathmouseX - an X coordinatemouseY - an Y coordinatetrue if the mouse cursor fall in the area of row that is used to expand/collapse the node and the node is not a leaf.protected void handleExpandControlClick(TreePath path, int mouseX, int mouseY)
toggleExpandState.path - a tree pathmouseX - an X coordinatemouseY - an Y coordinateprotected void toggleExpandState(TreePath path)
JTree scrolls on expand, ensureRowsAreVisible is invoked to scroll as many of the children to visible as possible (tries to scroll to last visible descendant of path).path - a tree pathprotected boolean isToggleSelectionEvent(MouseEvent event)
true signifies a mouse event on the node should toggle the selection of only the row under mouse.event - a mouse eventtrue if a mouse event on the node should toggle the selectionprotected boolean isMultiSelectEvent(MouseEvent event)
true signifies a mouse event on the node should select from the anchor point.event - a mouse eventtrue if a mouse event on the node should select from the anchor pointprotected boolean isToggleEvent(MouseEvent event)
true indicates the row under the mouse should be toggled based on the event. This is invoked after checkForClickInExpandControl, implying the location is not in the expand (toggle) control.event - a mouse eventtrue if the row under the mouse should be toggledprotected void selectPathForEvent(TreePath path, MouseEvent event)
MouseEvent over a particular row. If the event is a toggle selection event, the row is either selected, or deselected. If the event identifies a multi selection event, the selection is updated from the anchor point. Otherwise the row is selected, and if the event specified a toggle event the row is expanded/collapsed.path - the selected pathevent - the mouse eventprotected boolean isLeaf(int row)
true if the node at row is a leaf.row - a rowtrue if the node at row is a leafprotected void updateLeadSelectionRow()
protected int getLeadSelectionRow()
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/plaf/basic/BasicTreeUI.html