APIdia Launch Partner
Top Description Constructors Methods
javax.swing.plaf

public abstract Class TreeUI

extends ComponentUI
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.basic.BasicTreeUI, javax.swing.plaf.multi.MultiTreeUI
Imports
java.awt.Rectangle, javax.swing.JTree, javax.swing.tree.TreePath

Pluggable look and feel interface for JTree.
Authors
Rob Davis, Scott Violet

Constructor Summary

AccessConstructor and Description
protected
TreeUI()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public abstract void
cancelEditing(JTree
a JTree object
tree
)

Cancels the current editing session.

public abstract TreePath

Returns:

the TreePath node closest to x,y or null if there is nothing currently visible
getClosestPathForLocation
(JTree
a JTree object
tree
,
int
an integer giving the number of pixels horizontally from the left edge of the display area
x
,
int
an integer giving the number of pixels vertically from the top of the display area, minus any top margin
y
)

Returns the path to the node that is closest to x,y.

public abstract TreePath

Returns:

a TreePath containing the path to tree
getEditingPath
(JTree
the JTree for which to return a path
tree
)

Returns the path to the element that is being edited.

public abstract Rectangle

Returns:

the Rectangle enclosing the label portion that the last item in path will be drawn into, null if any component in path is currently valid.
getPathBounds
(JTree
the JTree for path
tree
,
TreePath
the TreePath identifying the node
path
)

Returns the Rectangle enclosing the label portion that the last item in path will be drawn into.

public abstract TreePath

Returns:

the path for row or null if row is not visible
getPathForRow
(JTree
a JTree object
tree
,
int
an integer specifying a row
row
)

Returns the path for passed in row.

public abstract int

Returns:

an integer specifying the number of row being displayed
getRowCount
(JTree
the JTree for which to count rows
tree
)

Returns the number of rows that are being displayed.

public abstract int

Returns:

an integer specifying the row at which the last item identified is visible, -1 if any of the elements in path are not currently visible
getRowForPath
(JTree
the JTree for path
tree
,
TreePath
the TreePath object to look in
path
)

Returns the row that the last item identified in path is visible at.

public abstract boolean

Returns:

true if tree is being edited
isEditing
(JTree
a JTree object
tree
)

Returns true if the tree is being edited.

public abstract void
startEditingAtPath(JTree
the JTree being edited
tree
,
TreePath
the TreePath to be edited
path
)

Selects the last item in path and tries to edit it.

public abstract boolean

Returns:

true if the editor allows the editing session to stop
stopEditing
(JTree
a JTree object
tree
)

Stops the current editing session.

Inherited from javax.swing.plaf.ComponentUI:
containscreateUIgetAccessibleChildgetAccessibleChildrenCountgetBaselinegetBaselineResizeBehaviorgetMaximumSizegetMinimumSizegetPreferredSizeinstallUIpaintuninstallUIupdate

Constructor Detail

TreeUIback to summary
protected TreeUI()

Constructor for subclasses to call.

Method Detail

cancelEditingback to summary
public abstract void cancelEditing(JTree tree)

Cancels the current editing session. This has no effect if the tree isn't being edited.

Parameters
tree:JTree

a JTree object

getClosestPathForLocationback to summary
public abstract TreePath getClosestPathForLocation(JTree tree, int x, int y)

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.

Parameters
tree:JTree

a JTree object

x:int

an integer giving the number of pixels horizontally from the left edge of the display area

y:int

an integer giving the number of pixels vertically from the top of the display area, minus any top margin

Returns:TreePath

the TreePath node closest to x,y or null if there is nothing currently visible

getEditingPathback to summary
public abstract TreePath getEditingPath(JTree tree)

Returns the path to the element that is being edited.

Parameters
tree:JTree

the JTree for which to return a path

Returns:TreePath

a TreePath containing the path to tree

getPathBoundsback to summary
public abstract Rectangle getPathBounds(JTree tree, TreePath path)

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 invalid.

Parameters
tree:JTree

the JTree for path

path:TreePath

the TreePath identifying the node

Returns:Rectangle

the Rectangle enclosing the label portion that the last item in path will be drawn into, null if any component in path is currently valid.

getPathForRowback to summary
public abstract TreePath getPathForRow(JTree tree, int row)

Returns the path for passed in row. If row is not visible null is returned.

Parameters
tree:JTree

a JTree object

row:int

an integer specifying a row

Returns:TreePath

the path for row or null if row is not visible

getRowCountback to summary
public abstract int getRowCount(JTree tree)

Returns the number of rows that are being displayed.

Parameters
tree:JTree

the JTree for which to count rows

Returns:int

an integer specifying the number of row being displayed

getRowForPathback to summary
public abstract int getRowForPath(JTree tree, TreePath path)

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.

Parameters
tree:JTree

the JTree for path

path:TreePath

the TreePath object to look in

Returns:int

an integer specifying the row at which the last item identified is visible, -1 if any of the elements in path are not currently visible

isEditingback to summary
public abstract boolean isEditing(JTree tree)

Returns true if the tree is being edited. The item that is being edited can be returned by getEditingPath().

Parameters
tree:JTree

a JTree object

Returns:boolean

true if tree is being edited

startEditingAtPathback to summary
public abstract void startEditingAtPath(JTree tree, TreePath path)

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.

Parameters
tree:JTree

the JTree being edited

path:TreePath

the TreePath to be edited

stopEditingback to summary
public abstract boolean stopEditing(JTree tree)

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.

Parameters
tree:JTree

a JTree object

Returns:boolean

true if the editor allows the editing session to stop