Uses of Class javax.swing.JTree (Java Platform SE 8 )
Date: 2026-04-22

## Uses of Class
javax.swing.JTree

- Packages that use JTree
  Package | Description
  --- | ---
  javax.swing | Provides a set of "lightweight" (all-Java language) components that, to the maximum degree possible, work the same on all platforms.
  javax.swing.plaf | Provides one interface and many abstract classes that Swing uses to provide its pluggable look-and-feel capabilities.
  javax.swing.plaf.basic | Provides user interface objects built according to the Basic look and feel.
  javax.swing.plaf.multi | Provides user interface objects that combine two or more look and feels.
  javax.swing.tree | Provides classes and interfaces for dealing with `javax.swing.JTree`.

- - ### Uses of JTree in javax.swing

    Methods in javax.swing with parameters of type JTree
    Modifier and Type | Method and Description
    --- | ---
    `Component` | DefaultCellEditor.`getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)` Implements the `TreeCellEditor` interface.

    Constructors in javax.swing with parameters of type JTree
    Constructor and Description
    `AccessibleJTreeNode(JTree t, TreePath p, Accessible ap)` Constructs an AccessibleJTreeNode

  - ### Uses of JTree in javax.swing.plaf

    Methods in javax.swing.plaf with parameters of type JTree
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | TreeUI.`cancelEditing(JTree tree)` Cancels the current editing session.
    `abstract TreePath` | TreeUI.`getClosestPathForLocation(JTree tree, int x, int y)` Returns the path to the node that is closest to x,y.
    `abstract TreePath` | TreeUI.`getEditingPath(JTree tree)` Returns the path to the element that is being edited.
    `abstract Rectangle` | TreeUI.`getPathBounds(JTree tree, TreePath path)` Returns the Rectangle enclosing the label portion that the last item in path will be drawn into.
    `abstract TreePath` | TreeUI.`getPathForRow(JTree tree, int row)` Returns the path for passed in row.
    `abstract int` | TreeUI.`getRowCount(JTree tree)` Returns the number of rows that are being displayed.
    `abstract int` | TreeUI.`getRowForPath(JTree tree, TreePath path)` Returns the row that the last item identified in path is visible at.
    `abstract boolean` | TreeUI.`isEditing(JTree tree)` Returns true if the tree is being edited.
    `abstract void` | TreeUI.`startEditingAtPath(JTree tree, TreePath path)` Selects the last item in path and tries to edit it.
    `abstract boolean` | TreeUI.`stopEditing(JTree tree)` Stops the current editing session.

  - ### Uses of JTree in javax.swing.plaf.basic

    Fields in javax.swing.plaf.basic declared as JTree
    Modifier and Type | Field and Description
    --- | ---
    `protected JTree` | BasicTreeUI.`tree` Component that we're going to be drawing into.

    Methods in javax.swing.plaf.basic with parameters of type JTree
    Modifier and Type | Method and Description
    --- | ---
    `void` | BasicTreeUI.`cancelEditing(JTree tree)` Cancels the current editing session.
    `TreePath` | BasicTreeUI.`getClosestPathForLocation(JTree tree, int x, int y)` Returns the path to the node that is closest to x,y.
    `TreePath` | BasicTreeUI.`getEditingPath(JTree tree)` Returns the path to the element that is being edited.
    `Rectangle` | BasicTreeUI.`getPathBounds(JTree tree, TreePath path)` Returns the Rectangle enclosing the label portion that the last item in path will be drawn into.
    `TreePath` | BasicTreeUI.`getPathForRow(JTree tree, int row)` Returns the path for passed in row.
    `int` | BasicTreeUI.`getRowCount(JTree tree)` Returns the number of rows that are being displayed.
    `int` | BasicTreeUI.`getRowForPath(JTree tree, TreePath path)` Returns the row that the last item identified in path is visible at.
    `boolean` | BasicTreeUI.`isEditing(JTree tree)` Returns true if the tree is being edited.
    `void` | BasicTreeUI.`startEditingAtPath(JTree tree, TreePath path)` Selects the last item in path and tries to edit it.
    `boolean` | BasicTreeUI.`stopEditing(JTree tree)` Stops the current editing session.

  - ### Uses of JTree in javax.swing.plaf.multi

    Methods in javax.swing.plaf.multi with parameters of type JTree
    Modifier and Type | Method and Description
    --- | ---
    `void` | MultiTreeUI.`cancelEditing(JTree a)` Invokes the `cancelEditing` method on each UI handled by this object.
    `TreePath` | MultiTreeUI.`getClosestPathForLocation(JTree a, int b, int c)` Invokes the `getClosestPathForLocation` method on each UI handled by this object.
    `TreePath` | MultiTreeUI.`getEditingPath(JTree a)` Invokes the `getEditingPath` method on each UI handled by this object.
    `Rectangle` | MultiTreeUI.`getPathBounds(JTree a, TreePath b)` Invokes the `getPathBounds` method on each UI handled by this object.
    `TreePath` | MultiTreeUI.`getPathForRow(JTree a, int b)` Invokes the `getPathForRow` method on each UI handled by this object.
    `int` | MultiTreeUI.`getRowCount(JTree a)` Invokes the `getRowCount` method on each UI handled by this object.
    `int` | MultiTreeUI.`getRowForPath(JTree a, TreePath b)` Invokes the `getRowForPath` method on each UI handled by this object.
    `boolean` | MultiTreeUI.`isEditing(JTree a)` Invokes the `isEditing` method on each UI handled by this object.
    `void` | MultiTreeUI.`startEditingAtPath(JTree a, TreePath b)` Invokes the `startEditingAtPath` method on each UI handled by this object.
    `boolean` | MultiTreeUI.`stopEditing(JTree a)` Invokes the `stopEditing` method on each UI handled by this object.

  - ### Uses of JTree in javax.swing.tree

    Fields in javax.swing.tree declared as JTree
    Modifier and Type | Field and Description
    --- | ---
    `protected JTree` | DefaultTreeCellEditor.`tree` `JTree` instance listening too.

    Methods in javax.swing.tree with parameters of type JTree
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | DefaultTreeCellEditor.`determineOffset(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)`
    `Component` | DefaultTreeCellEditor.`getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)` Configures the editor.
    `Component` | TreeCellEditor.`getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)` Sets an initial value for the editor.
    `Component` | TreeCellRenderer.`getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)` Sets the value of the current tree cell to `value`.
    `Component` | DefaultTreeCellRenderer.`getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)` Configures the renderer based on the passed in components.
    `protected void` | DefaultTreeCellEditor.`setTree(JTree newTree)` Sets the tree currently editing for.

    Constructors in javax.swing.tree with parameters of type JTree
    Constructor and Description
    `DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer)` Constructs a `DefaultTreeCellEditor` object for a JTree using the specified renderer and a default editor.
    `DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer, TreeCellEditor editor)` Constructs a `DefaultTreeCellEditor` object for a `JTree` using the specified renderer and the specified editor.

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.