javax.swing.plaf

Class TreeUI

public abstract class TreeUI extends ComponentUI

An abstract base class for delegates that provide the user interface for JTree.

See Also:

Constructor Summary
TreeUI()
Constructs a new TreeUI.
Method Summary
abstract voidcancelEditing(JTree tree)
Cancels editing a tree cell, discarding any entered value.
abstract TreePathgetClosestPathForLocation(JTree tree, int x, int y)
Finds the path that is closest to the specified position.
abstract TreePathgetEditingPath(JTree tree)
Retrieves the tree cell that is currently being edited.
abstract RectanglegetPathBounds(JTree tree, TreePath path)
Determines the geometric extent of the label that is drawn for a path.
abstract TreePathgetPathForRow(JTree tree, int row)
Creates a TreePath for the specified row.
abstract intgetRowCount(JTree tree)
Counts how many rows are currently displayed.
abstract intgetRowForPath(JTree tree, TreePath path)
Determines in which row a TreePath is currently being displayed.
abstract booleanisEditing(JTree tree)
Determines whether the user is currently editing a tree cell.
abstract voidstartEditingAtPath(JTree tree, TreePath path)
Starts a session to edit a tree cell.
abstract booleanstopEditing(JTree tree)
Stops editing a tree cell, committing the entered value into the tree’s model.

Constructor Detail

TreeUI

public TreeUI()
Constructs a new TreeUI.

Method Detail

cancelEditing

public abstract void cancelEditing(JTree tree)
Cancels editing a tree cell, discarding any entered value. If no editing session is active, nothing happens. The cell editor is not given an opportunity to veto the canceling. In some look and feels, this action happens when the user has pressed the escape key.

Parameters: tree the JTree for which this delegate object provides the user interface.

getClosestPathForLocation

public abstract TreePath getClosestPathForLocation(JTree tree, int x, int y)
Finds the path that is closest to the specified position.

[A screen shot of a JTree]

As shown by the above illustration, the bounds of the closest path do not necessarily need to contain the passed location.

Parameters: tree the JTree for which this delegate object provides the user interface. x the horizontal location, relative to the origin of tree. y the vertical location, relative to the origin of tree.

Returns: the closest path, or null if the tree is currenlty not displaying any paths at all.

getEditingPath

public abstract TreePath getEditingPath(JTree tree)
Retrieves the tree cell that is currently being edited.

Returns: the currently edited path, or null if no editing session is currently active.

getPathBounds

public abstract Rectangle getPathBounds(JTree tree, TreePath path)
Determines the geometric extent of the label that is drawn for a path.

Parameters: tree the JTree for which this delegate object provides the user interface. path the path whose label extent is requested.

Returns: a rectangle enclosing the label, or null if path contains invalid nodes.

getPathForRow

public abstract TreePath getPathForRow(JTree tree, int row)
Creates a TreePath for the specified row.

Parameters: tree the JTree for which this delegate object provides the user interface. row the index of the row, which should be a number in the range [0, getRowCount(tree) - 1].

Returns: a TreePath for the specified row, or null if row is outside the valid range.

getRowCount

public abstract int getRowCount(JTree tree)
Counts how many rows are currently displayed.

Parameters: tree the JTree for which this delegate object provides the user interface.

Returns: the number of visible rows.

getRowForPath

public abstract int getRowForPath(JTree tree, TreePath path)
Determines in which row a TreePath is currently being displayed.

Parameters: tree the JTree for which this delegate object provides the user interface. path the path for which the caller wants to know in which row it is being displayed.

Returns: a number in the range [0, getRowCount(tree) - 1] if the path is currently on display; -1 if the path is not shown to the user.

isEditing

public abstract boolean isEditing(JTree tree)
Determines whether the user is currently editing a tree cell.

Parameters: tree the JTree for which this delegate object provides the user interface.

See Also: TreeUI

startEditingAtPath

public abstract void startEditingAtPath(JTree tree, TreePath path)
Starts a session to edit a tree cell. If the cell editor rejects editing the cell, it will just be selected.

Parameters: tree the JTree for which this delegate object provides the user interface. path the cell to edit.

stopEditing

public abstract boolean stopEditing(JTree tree)
Stops editing a tree cell, committing the entered value into the tree’s model. If no editing session is active, or if the active editor does not agree to stopping, nothing happens. In some look and feels, this action happens when the user has pressed the enter key.

Parameters: tree the JTree for which this delegate object provides the user interface.

Returns: false if the editing still goes on because the cell editor has objected to stopping the session; true if editing has been stopped.