java.lang.Objectjavax.swing.tree.TreePath
public class TreePath
Represents a path to a node. A TreePath is an array of Objects that are vended from a TreeModel. The elements of the array are ordered such that the root is always the first element (index 0) of the array. TreePath is Serializable, but if any components of the path are not serializable, it will not be written out.
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 JavaBeans TM has been added to the java.beans package. Please see XMLEncoder .
Constructor Summary | |
---|---|
protected |
TreePath
() Primarily provided for subclasses that represent paths in a different manner. |
TreePath
(
Object
singlePath) Constructs a TreePath containing only a single element. |
|
TreePath
(
Object
[] path) 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. |
|
protected |
TreePath
(
Object
[] path, int length) Constructs a new TreePath with the identified path components of length length. |
protected |
TreePath
(
TreePath
parent,
Object
lastElement) Constructs a new TreePath, which is the path identified by parent ending in lastElement. |
Method Summary | |
---|---|
boolean |
equals
(
Object
o) Tests two TreePaths for equality by checking each element of the paths for equality. |
Object |
getLastPathComponent
() Returns the last component of this path. |
TreePath |
getParentPath
() Returns a path containing all the elements of this object, except the last path component. |
Object [] |
getPath
() Returns an ordered array of Objects containing the components of this TreePath. |
Object |
getPathComponent
(int element) Returns the path component at the specified index. |
int |
getPathCount
() Returns the number of elements in the path. |
int |
hashCode
() Returns the hashCode for the object. |
boolean |
isDescendant
(
TreePath
aTreePath) Returns true if aTreePath is a descendant of this TreePath. |
TreePath |
pathByAddingChild
(
Object
child) Returns a new path containing all the elements of this object plus child. |
String |
toString
() Returns a string that displays and identifies this object's properties. |
Methods inherited from class java.lang. Object |
---|
clone , finalize , getClass , notify , notifyAll , wait , wait , wait |
Constructor Detail |
---|
public TreePath(Object[] path)
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)
protected TreePath(TreePath parent, Object lastElement)
protected TreePath(Object[] path, int length)
protected TreePath()
Method Detail |
---|
public Object[] getPath()
public Object getLastPathComponent()
public int getPathCount()
public Object getPathComponent(int element)
public boolean equals(Object o)
public int hashCode()
public boolean isDescendant(TreePath aTreePath)
public TreePath pathByAddingChild(Object child)
public TreePath getParentPath()
public String toString()