src/share/classes/javax/swing/tree/TreePath.java

Print this page




  49  *   DefaultTreeModel model = new DefaultTreeModel(root);
  50  *   JTree tree = new JTree(model);
  51  *   ...
  52  *   TreePath selectedPath = tree.getSelectionPath();
  53  *   DefaultMutableTreeNode selectedNode =
  54  *       ((DefaultMutableTreeNode)selectedPath.getLastPathComponent()).
  55  *       getUserObject();
  56  * </pre>
  57  * Subclasses typically need override only {@code
  58  * getLastPathComponent}, and {@code getParentPath}. As {@code JTree}
  59  * internally creates {@code TreePath}s at various points, it's
  60  * generally not useful to subclass {@code TreePath} and use with
  61  * {@code JTree}.
  62  * <p>
  63  * While {@code TreePath} is serializable, a {@code
  64  * NotSerializableException} is thrown if any elements of the path are
  65  * not serializable.
  66  * <p>
  67  * For further information and examples of using tree paths,
  68  * see <a
  69  href="http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html">How to Use Trees</a>
  70  * in <em>The Java Tutorial.</em>
  71  * <p>
  72  * <strong>Warning:</strong>
  73  * Serialized objects of this class will not be compatible with
  74  * future Swing releases. The current serialization support is
  75  * appropriate for short term storage or RMI between applications running
  76  * the same version of Swing.  As of 1.4, support for long term storage
  77  * of all JavaBeans<sup><font size="-2">TM</font></sup>
  78  * has been added to the <code>java.beans</code> package.
  79  * Please see {@link java.beans.XMLEncoder}.
  80  *
  81  * @author Scott Violet
  82  * @author Philip Milne
  83  */
  84 public class TreePath extends Object implements Serializable {
  85     /** Path representing the parent, null if lastPathComponent represents
  86      * the root. */
  87     private TreePath           parentPath;
  88     /** Last path component. */
  89     private Object lastPathComponent;




  49  *   DefaultTreeModel model = new DefaultTreeModel(root);
  50  *   JTree tree = new JTree(model);
  51  *   ...
  52  *   TreePath selectedPath = tree.getSelectionPath();
  53  *   DefaultMutableTreeNode selectedNode =
  54  *       ((DefaultMutableTreeNode)selectedPath.getLastPathComponent()).
  55  *       getUserObject();
  56  * </pre>
  57  * Subclasses typically need override only {@code
  58  * getLastPathComponent}, and {@code getParentPath}. As {@code JTree}
  59  * internally creates {@code TreePath}s at various points, it's
  60  * generally not useful to subclass {@code TreePath} and use with
  61  * {@code JTree}.
  62  * <p>
  63  * While {@code TreePath} is serializable, a {@code
  64  * NotSerializableException} is thrown if any elements of the path are
  65  * not serializable.
  66  * <p>
  67  * For further information and examples of using tree paths,
  68  * see <a
  69  href="http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html">How to Use Trees</a>
  70  * in <em>The Java Tutorial.</em>
  71  * <p>
  72  * <strong>Warning:</strong>
  73  * Serialized objects of this class will not be compatible with
  74  * future Swing releases. The current serialization support is
  75  * appropriate for short term storage or RMI between applications running
  76  * the same version of Swing.  As of 1.4, support for long term storage
  77  * of all JavaBeans<sup><font size="-2">TM</font></sup>
  78  * has been added to the <code>java.beans</code> package.
  79  * Please see {@link java.beans.XMLEncoder}.
  80  *
  81  * @author Scott Violet
  82  * @author Philip Milne
  83  */
  84 public class TreePath extends Object implements Serializable {
  85     /** Path representing the parent, null if lastPathComponent represents
  86      * the root. */
  87     private TreePath           parentPath;
  88     /** Last path component. */
  89     private Object lastPathComponent;