| public class javax.swing.tree TreePath
|
Java SE 6 |
For further information and examples of using tree paths, see How to Use Trees in The Java Tutorial.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see java.beans.XMLEncoder.
| version | 1.31 11/17/05 |
| Constructors | |||||
|---|---|---|---|---|---|
| public | TreePath(Object[] path) Details
Constructs a path from an array of Objects, uniquely identifying
the path from the root of the tree to a specific node, as returned
by the tree's data model.
The model is free to return an array of any Objects it needs to represent the path. The DefaultTreeModel returns an array of TreeNode objects. The first TreeNode in the path is the root of the tree, the last TreeNode is the node identified by the path.
| ||||
| public | TreePath(Object singlePath) Details
Constructs a TreePath containing only a single element. This is
usually used to construct a TreePath for the the root of the TreeModel.
| ||||
| protected | TreePath(TreePath parent, Object lastElement) Constructs a new TreePath, which is the path identified by parent ending in lastElement.
| ||||
| protected | TreePath(Object[] path, int length) Constructs a new TreePath with the identified path components of length length.
| ||||
| protected | TreePath() Primarily provided for subclasses that represent paths in a different manner. If a subclass uses this constructor, it should also override the getPath,
getPathCount, and
getPathComponent methods,
and possibly the equals method.
| ||||
| Methods | |||
|---|---|---|---|
| public boolean | equals(Object o) Details
Tests two TreePaths for equality by checking each element of the
paths for equality. Two paths are considered equal if they are of
the same length, and contain
the same elements ( .equals).
| ||
| public int | hashCode() Details
Returns the hashCode for the object. The hash code of a TreePath
is defined to be the hash code of the last component in the path.
| ||
| public TreePath | pathByAddingChild(Object child) Returns a new path containing all the elements of this object plus child. child will be the last element
of the newly created TreePath.
This will throw a NullPointerException
if child is null.
| ||
| public String | toString() Details
Returns a string that displays and identifies this
object's properties.
| ||
| Properties | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| public boolean | isDescendant(TreePath aTreePath) Details
Returns true if aTreePath is a
descendant of this
TreePath. A TreePath P1 is a descendant of a TreePath P2
if P1 contains all of the components that make up
P2's path.
For example, if this object has the path [a, b],
and aTreePath has the path [a, b, c],
then aTreePath is a descendant of this object.
However, if aTreePath has the path [a],
then it is not a descendant of this object. By this definition
a TreePath is always considered a descendant of itself. That is,
aTreePath.isDescendant(aTreePath) returns true.
| ||||||||
| public Object | getLastPathComponent() Details
Returns the last component of this path. For a path returned by
DefaultTreeModel this will return an instance of TreeNode.
| ||||||||
| public TreePath | getParentPath() Returns a path containing all the elements of this object, except the last path component. | ||||||||
| public Object[] | getPath() Details
Returns an ordered array of Objects containing the components of this
TreePath. The first element (index 0) is the root.
| ||||||||
| public Object | getPathComponent(int element) Details
Returns the path component at the specified index.
| ||||||||
| public int | getPathCount() Details
Returns the number of elements in the path.
| ||||||||
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2009 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|