All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.tree.TreePath

java.lang.Object
   |
   +----com.sun.java.swing.tree.TreePath

public class TreePath
extends Object
implements Serializable
Represents a path to a node. TreePath is Serializable, but if any components of the path are not serializable, it will not be written out.

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 Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.


Variable Index

 o path
Path this instance represents.

Constructor Index

 o TreePath(Object)
Constructs a TreePath when there is only item in the path.
 o TreePath(Object[])
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.

Method Index

 o equals(Object)
Tests two TreePaths for equality by checking each element of the paths for equality.
 o getLastPathComponent()
Returns the last component of this path.
 o getPath()
Returns an array of Objects containing the components of this TreePath.
 o getPathComponent(int)
Returns the path component at the specified index.
 o getPathCount()
Returns the number of elements in the path.
 o hashCode()
Returns the hashCode for the object.
 o isDescendant(TreePath)
Returns true if the specified node is a descendant of this TreePath.
 o toString()
Returns a string that displays and identifies this object's properties.

Variables

 o path
 protected transient Object path[]
Path this instance represents.

Constructors

 o TreePath
 public 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.

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.

Parameters:
path - an array of Objects representing the path to a node
 o TreePath
 public TreePath(Object singlePath)
Constructs a TreePath when there is only item in the path.

Parameters:
singlePath - an Object representing the path to a node
See Also:
TreePath

Methods

 o getPath
 public Object[] getPath()
Returns an array of Objects containing the components of this TreePath.

Returns:
an array of Objects representing the TreePath
See Also:
TreePath
 o getLastPathComponent
 public Object getLastPathComponent()
Returns the last component of this path. For a path returned by the DefaultTreeModel, that is the TreeNode object for the node specified by the path.

Returns:
the Object at the end of the path
See Also:
TreePath
 o getPathCount
 public int getPathCount()
Returns the number of elements in the path.

Returns:
an int giving a count of items the path
 o getPathComponent
 public Object getPathComponent(int element)
Returns the path component at the specified index.

Parameters:
element - an int specifying an element in the path, where 0 is the first element in the path
Returns:
the Object at that index location
See Also:
TreePath
 o equals
 public boolean equals(Object o)
Tests two TreePaths for equality by checking each element of the paths for equality.

Parameters:
o - the Object to compare
Overrides:
equals in class Object
 o hashCode
 public int hashCode()
Returns the hashCode for the object. This must be defined here to ensure 100% pure.

Returns:
the hashCode for the object
Overrides:
hashCode in class Object
 o isDescendant
 public boolean isDescendant(TreePath aTreePath)
Returns true if the specified node is a descendant of this TreePath. A TreePath, child, is a descendent of another TreePath, parent, if child contains all of the components that make up parent's path.

Returns:
true if aTreePath is a descendant of the receiver.
 o toString
 public String toString()
Returns a string that displays and identifies this object's properties.

Returns:
a String representation of this object
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index