java.lang.Object | |||
↳ | javax.swing.plaf.ComponentUI | ||
↳ | javax.swing.plaf.TreeUI | ||
↳ | javax.swing.plaf.basic.BasicTreeUI |
![]() |
The basic L&F for a hierarchical data structure.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
BasicTreeUI.CellEditorHandler | Listener responsible for getting cell editing events and updating the tree accordingly. | ||||||||||
BasicTreeUI.ComponentHandler | Updates the preferred size when scrolling (if necessary). | ||||||||||
BasicTreeUI.FocusHandler | Repaints the lead selection row when focus is lost/gained. | ||||||||||
BasicTreeUI.KeyHandler | This is used to get mutliple key down events to appropriately generate events. | ||||||||||
BasicTreeUI.MouseHandler | TreeMouseListener is responsible for updating the selection based on mouse events. | ||||||||||
BasicTreeUI.MouseInputHandler | MouseInputHandler handles passing all mouse events, including mouse motion events, until the mouse is released to the destination it is constructed with. | ||||||||||
BasicTreeUI.NodeDimensionsHandler | Class responsible for getting size of node, method is forwarded to BasicTreeUI method. | ||||||||||
BasicTreeUI.PropertyChangeHandler | PropertyChangeListener for the tree. | ||||||||||
BasicTreeUI.SelectionModelPropertyChangeHandler | Listener on the TreeSelectionModel, resets the row selection if any of the properties of the model change. | ||||||||||
BasicTreeUI.TreeCancelEditingAction | ActionListener that invokes cancelEditing when action performed. | ||||||||||
BasicTreeUI.TreeExpansionHandler | Updates the TreeState in response to nodes expanding/collapsing. | ||||||||||
BasicTreeUI.TreeHomeAction | TreeHomeAction is used to handle end/home actions. | ||||||||||
BasicTreeUI.TreeIncrementAction | TreeIncrementAction is used to handle up/down actions. | ||||||||||
BasicTreeUI.TreeModelHandler | Forwards all TreeModel events to the TreeState. | ||||||||||
BasicTreeUI.TreePageAction | TreePageAction handles page up and page down events. | ||||||||||
BasicTreeUI.TreeSelectionHandler | Listens for changes in the selection model and updates the display accordingly. | ||||||||||
BasicTreeUI.TreeToggleAction | For the first selected row expandedness will be toggled. | ||||||||||
BasicTreeUI.TreeTraverseAction | TreeTraverseAction is the action used for left/right keys. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
cellEditor | Editor for the tree. | ||||||||||
collapsedIcon | |||||||||||
createdCellEditor | Set to true if editor that is currently in the tree was created by this instance. | ||||||||||
createdRenderer | Set to true if the renderer that is currently in the tree was created by this instance. | ||||||||||
currentCellRenderer | Renderer that is being used to do the actual cell drawing. | ||||||||||
depthOffset | How much the depth should be offset to properly calculate x locations. | ||||||||||
drawingCache | Used for minimizing the drawing of vertical lines. | ||||||||||
editingComponent | When editing, this will be the Component that is doing the actual editing. | ||||||||||
editingPath | Path that is being edited. | ||||||||||
editingRow | Row that is being edited. | ||||||||||
editorHasDifferentSize | Set to true if the editor has a different size than the renderer. | ||||||||||
expandedIcon | |||||||||||
largeModel | True if doing optimizations for a largeModel. | ||||||||||
lastSelectedRow | Index of the row that was last selected. | ||||||||||
leftChildIndent | Distance between left margin and where vertical dashes will be drawn. | ||||||||||
nodeDimensions | Reponsible for telling the TreeState the size needed for a node. | ||||||||||
preferredMinSize | Minimum preferred size. | ||||||||||
preferredSize | Size needed to completely display all the nodes. | ||||||||||
rendererPane | Used to paint the TreeCellRenderer. | ||||||||||
rightChildIndent | Distance to add to leftChildIndent to determine where cell contents will be drawn. | ||||||||||
stopEditingInCompleteEditing | Set to false when editing and shouldSelectCell() returns true meaning the node should be selected before editing, used in completeEditing. | ||||||||||
totalChildIndent | Total distance that will be indented. | ||||||||||
tree | Component that we're going to be drawing into. | ||||||||||
treeModel | Used to determine what to display. | ||||||||||
treeSelectionModel | Model maintaing the selection. | ||||||||||
treeState | Object responsible for handling sizing and expanded issues. | ||||||||||
validCachedPreferredSize | Is the preferredSize valid? |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Cancels the current editing session.
| |||||||||||
Returns the baseline.
| |||||||||||
Returns an enum indicating how the baseline of the component
changes as the size changes.
| |||||||||||
Returns the path to the node that is closest to x,y.
| |||||||||||
Returns the path to the element that is being edited.
| |||||||||||
Returns the maximum size for this component, which will be the
preferred size if the instance is currently in a JTree, or 0, 0.
| |||||||||||
Returns the minimum size for this component.
| |||||||||||
Returns the Rectangle enclosing the label portion that the
last item in path will be drawn into.
| |||||||||||
Returns the path for passed in row.
| |||||||||||
Returns the minimum preferred size.
| |||||||||||
Returns the preferred size to properly display the tree,
this is a cover method for getPreferredSize(c, false).
| |||||||||||
Returns the preferred size to represent the tree in
c.
| |||||||||||
Returns the number of rows that are being displayed.
| |||||||||||
Returns the row that the last item identified in path is visible
at.
| |||||||||||
Configures the specified component appropriate for the look and feel.
| |||||||||||
Returns true if the tree is being edited.
| |||||||||||
Paints the specified component appropriate for the look and feel.
| |||||||||||
Sets the preferred minimum size.
| |||||||||||
Selects the last item in path and tries to edit it.
| |||||||||||
Stops the current editing session.
| |||||||||||
Reverses configuration which was done on the specified component during
installUI . |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
If the
mouseX and mouseY are in the
expand/collapse region of the row , this will toggle
the row. | |||||||||||
Messages to stop the editing session.
| |||||||||||
Stops the editing session.
| |||||||||||
Invoked from installUI after all the defaults/listeners have been
installed.
| |||||||||||
Resets the TreeState instance based on the tree we're providing the
look and feel for.
| |||||||||||
Creates a listener to handle events from the current editor.
| |||||||||||
Returns the renderer pane that renderer components are placed in.
| |||||||||||
Creates and returns a new ComponentHandler.
| |||||||||||
Creates a default cell editor.
| |||||||||||
Returns the default cell renderer that is used to do the
stamping of each node.
| |||||||||||
Creates a listener that is responsible for updating the display
when focus is lost/gained.
| |||||||||||
Creates the listener reponsible for getting key events from
the tree.
| |||||||||||
Creates the object responsible for managing what is expanded, as
well as the size of nodes.
| |||||||||||
Creates the listener responsible for updating the selection based on
mouse events.
| |||||||||||
Creates an instance of NodeDimensions that is able to determine
the size of a given node in the tree.
| |||||||||||
Creates a listener that is responsible that updates the UI based on
how the tree changes.
| |||||||||||
Creates the listener responsible for getting property change
events from the selection model.
| |||||||||||
Creates and returns the object responsible for updating the treestate
when nodes expanded state changes.
| |||||||||||
Returns a listener that can update the tree when the model changes.
| |||||||||||
Creates the listener that updates the display based on selection change
methods.
| |||||||||||
Ensures that the rows identified by beginRow through endRow are
visible.
| |||||||||||
Return currentCellRenderer, which will either be the trees
renderer, or defaultCellRenderer, which ever wasn't null.
| |||||||||||
The horizontal element of legs between nodes starts at the
right of the left-hand side of the child node by default.
| |||||||||||
Returns a path to the last child of
parent . | |||||||||||
Returns the location, along the x-axis, to render a particular row
at.
| |||||||||||
The vertical element of legs between nodes starts at the bottom of the
parent node by default.
| |||||||||||
Messaged when the user clicks the particular row, this invokes
toggleExpandState.
| |||||||||||
Intalls the subcomponents of the tree, which is the renderer pane.
| |||||||||||
Returns 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. | |||||||||||
Returning true signifies a mouse event on the node should select
from the anchor point.
| |||||||||||
Returning true indicates the row under the mouse should be toggled
based on the event.
| |||||||||||
Returning true signifies a mouse event on the node should toggle
the selection of only the row under mouse.
| |||||||||||
Paints the expand (toggle) part of a row.
| |||||||||||
Paints a horizontal line.
| |||||||||||
Paints the horizontal part of the leg.
| |||||||||||
Paints the renderer part of a row.
| |||||||||||
Paints a vertical line.
| |||||||||||
Paints the vertical part of the leg.
| |||||||||||
Messaged from the VisibleTreeNode after it has collapsed.
| |||||||||||
Messaged from the VisibleTreeNode after it has been expanded.
| |||||||||||
Invoked after the
tree instance variable has been
set, but before any defaults/listeners have been installed. | |||||||||||
Messaged to update the selection based on a MouseEvent over a
particular row.
| |||||||||||
Sets the cell editor.
| |||||||||||
Sets the TreeCellRenderer to
tcr . | |||||||||||
Configures the receiver to allow, or not allow, editing.
| |||||||||||
Updates the componentListener, if necessary.
| |||||||||||
Sets the TreeModel.
| |||||||||||
Sets the root to being visible.
| |||||||||||
Sets the row height, this is forwarded to the treeState.
| |||||||||||
Resets the selection model.
| |||||||||||
Determines whether the node handles are to be displayed.
| |||||||||||
Returns true if the expand (toggle) control should be drawn for
the specified row.
| |||||||||||
Will start editing for node if there is a cellEditor and
shouldSelectCell returns true.
| |||||||||||
Expands path if it is not expanded, or collapses row if it is expanded.
| |||||||||||
Uninstalls the renderer pane.
| |||||||||||
Updates the
preferredSize instance variable,
which is returned from getPreferredSize() . | |||||||||||
Updates the cellEditor based on the editability of the JTree that
we're contained in.
| |||||||||||
Updates how much each depth should be offset by.
| |||||||||||
Updates the expanded state of all the descendants of
path
by getting the expanded descendants from the tree and forwarding
to the tree state. | |||||||||||
Makes all the nodes that are expanded in JTree expanded in LayoutCache.
| |||||||||||
Messaged from the tree we're in when the renderer has changed.
| |||||||||||
Marks the cached size as being invalid, and messages the
tree with
treeDidChange . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
Set to true if editor that is currently in the tree was created by this instance.
Set to true if the renderer that is currently in the tree was created by this instance.
Renderer that is being used to do the actual cell drawing.
How much the depth should be offset to properly calculate x locations. This is based on whether or not the root is visible, and if the root handles are visible.
Used for minimizing the drawing of vertical lines.
When editing, this will be the Component that is doing the actual editing.
Row that is being edited. Should only be referenced if editingComponent is not null.
Set to true if the editor has a different size than the renderer.
True if doing optimizations for a largeModel. Subclasses that don't support this may wish to override createLayoutCache to not return a FixedHeightLayoutCache instance.
Index of the row that was last selected.
Distance between left margin and where vertical dashes will be drawn.
Reponsible for telling the TreeState the size needed for a node.
Distance to add to leftChildIndent to determine where cell contents will be drawn.
Set to false when editing and shouldSelectCell() returns true meaning the node should be selected before editing, used in completeEditing.
Total distance that will be indented. The sum of leftChildIndent and rightChildIndent.
Is the preferredSize valid?
Returns the baseline.
c | JComponent baseline is being requested for |
---|---|
width | the width to get the baseline for |
height | the height to get the baseline for |
Returns an enum indicating how the baseline of the component changes as the size changes.
c | JComponent to return baseline resize behavior for |
---|
NullPointerException |
---|
Returns the path to the node that is closest to x,y. If there is nothing currently visible this will return null, otherwise it'll always return a valid path. If you need to test if the returned object is exactly at x, y you should get the bounds for the returned path and test x, y against that.
Returns the maximum size for this component, which will be the preferred size if the instance is currently in a JTree, or 0, 0.
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 components |
---|
Dimension
object or null
Returns the minimum size for this component. Which will be the min preferred size or 0, 0.
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 components |
---|
Dimension
object or null
Returns the Rectangle enclosing the label portion that the last item in path will be drawn into. Will return null if any component in path is currently valid.
Returns the path for passed in row. If row is not visible null is returned.
Returns the preferred size to properly display the tree, this is a cover method for getPreferredSize(c, false).
c | the component whose preferred size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
---|
Returns the preferred size to represent the tree in c. If checkConsistancy is true checkConsistancy is messaged first.
Returns the row that the last item identified in path is visible at. Will return -1 if any of the elements in path are not currently visible.
Configures the specified component appropriate for the look and feel.
This method is invoked when the ComponentUI
instance is being installed
as the UI delegate on the specified component. This method should
completely configure the component for the look and feel,
including the following:
LayoutManager
on the component if necessary.
PropertyChangeListener
on the component in order
to detect and respond to component property changes appropriately.
c | the component where this UI delegate is being installed |
---|
Returns true if the tree is being edited. The item that is being edited can be returned by getEditingPath().
Paints the specified component appropriate for the look and feel.
This method is invoked from the ComponentUI.update
method when
the specified component is being painted. Subclasses should override
this method and use the specified Graphics
object to
render the content of the component.
g | the Graphics context in which to paint |
---|---|
c | the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
Selects the last item in path and tries to edit it. Editing will fail if the CellEditor won't allow it for the selected item.
Stops the current editing session. This has no effect if the tree isn't being edited. Returns true if the editor allows the editing session to stop.
Reverses configuration which was done on the specified component during
installUI
. This method is invoked when this
UIComponent
instance is being removed as the UI delegate
for the specified component. This method should undo the
configuration performed in installUI
, being careful to
leave the JComponent
instance in a clean state (no
extraneous listeners, look-and-feel-specific property objects, etc.).
This should include the following:
c | the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
---|
If the mouseX
and mouseY
are in the
expand/collapse region of the row
, this will toggle
the row.
Messages to stop the editing session. If the UI the receiver
is providing the look and feel for returns true from
getInvokesStopCellEditing
, stopCellEditing will
invoked on the current editor. Then completeEditing will
be messaged with false, true, false to cancel any lingering
editing.
Stops the editing session. If 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.
Invoked from installUI after all the defaults/listeners have been installed.
Resets the TreeState instance based on the tree we're providing the look and feel for.
Creates a listener to handle events from the current editor.
Returns the renderer pane that renderer components are placed in.
Creates and returns a new ComponentHandler. This is used for the large model to mark the validCachedPreferredSize as invalid when the component moves.
Returns the default cell renderer that is used to do the stamping of each node.
Creates a listener that is responsible for updating the display when focus is lost/gained.
Creates the listener reponsible for getting key events from the tree.
Creates the object responsible for managing what is expanded, as well as the size of nodes.
Creates the listener responsible for updating the selection based on mouse events.
Creates an instance of NodeDimensions that is able to determine the size of a given node in the tree.
Creates a listener that is responsible that updates the UI based on how the tree changes.
Creates the listener responsible for getting property change events from the selection model.
Creates and returns the object responsible for updating the treestate when nodes expanded state changes.
Returns a listener that can update the tree when the model changes.
Creates the listener that updates the display based on selection change methods.
Ensures that the rows identified by beginRow through endRow are visible.
Return currentCellRenderer, which will either be the trees renderer, or defaultCellRenderer, which ever wasn't null.
The horizontal element of legs between nodes starts at the right of the left-hand side of the child node by default. This method makes the leg end before that.
Returns the location, along the x-axis, to render a particular row at. The return value does not include any Insets specified on the JTree. This does not check for the validity of the row or depth, it is assumed to be correct and will not throw an Exception if the row or depth doesn't match that of the tree.
row | Row to return x location for |
---|---|
depth | Depth of the row |
The vertical element of legs between nodes starts at the bottom of the parent node by default. This method makes the leg start below that.
Messaged when the user clicks the particular row, this invokes toggleExpandState.
Intalls the subcomponents of the tree, which is the renderer pane.
row
is a leaf.
Returns 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.
Returning true signifies a mouse event on the node should select from the anchor point.
Returning 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
Returning true signifies a mouse event on the node should toggle the selection of only the row under mouse.
Paints the expand (toggle) part of a row. The receiver should
NOT modify clipBounds
, or insets
.
Paints a horizontal line.
Paints the horizontal part of the leg. The receiver should
NOT modify clipBounds
, or insets
.
NOTE: parentRow
can be -1 if the root is not visible.
Paints the renderer part of a row. The receiver should
NOT modify clipBounds
, or insets
.
Paints a vertical line.
Paints the vertical part of the leg. The receiver should
NOT modify clipBounds
, insets
.
Messaged from the VisibleTreeNode after it has collapsed.
Messaged from the VisibleTreeNode after it has been expanded.
Invoked after the tree
instance variable has been
set, but before any defaults/listeners have been installed.
Messaged to update the selection based on a 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.
Sets the TreeCellRenderer to tcr
. This invokes
updateRenderer
.
Configures the receiver to allow, or not allow, editing.
Updates the componentListener, if necessary.
Sets the root to being visible.
Sets the row height, this is forwarded to the treeState.
Resets the selection model. The appropriate listener are installed on the model.
Determines whether the node handles are to be displayed.
Returns true if the expand (toggle) control should be drawn for the specified row.
Will start editing for node if there is a cellEditor and shouldSelectCell returns true.
This assumes that path is valid and visible.
Expands path if it is not expanded, or collapses row if it is expanded. If expanding a path and 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).
Uninstalls the renderer pane.
Updates the 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.
Updates the cellEditor based on the editability of the JTree that we're contained in. If the tree is editable but doesn't have a cellEditor, a basic one will be used.
Updates how much each depth should be offset by.
Updates the expanded state of all the descendants of path
by getting the expanded descendants from the tree and forwarding
to the tree state.
Makes all the nodes that are expanded in JTree expanded in LayoutCache. This invokes updateExpandedDescendants with the root path.
Messaged from the tree we're in when the renderer has changed.
Marks the cached size as being invalid, and messages the
tree with treeDidChange
.