Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## charvax.swing
Class JTree

    java.lang.Object
      charvax.swing.JTree

public class JTree
extends java.lang.Object

(UNDER CONSTRUCTION) A component that displays hierarchical data.

Field Summary
`protected TreeSelectionModel` | `_selectionModel`
`protected TreeModel` | `_treeModel`
`protected int` | `_visibleRowCount`

Constructor Summary
`JTree(TreeNode root)` Returns a JTree with the specified TreeNode as its root, which displays the root node.
`JTree(TreeNode root, boolean asksAllowsChildren)` Returns a JTree with the specified TreeNode as its root, which displays the root node and which decides whether a node is a leaf node in the specified manner.

Method Summary
`void` | `clearSelection()` Clears the selection.
`void` | `collapsePath(TreePath path)` Ensures that the node identified by the specified path is collapsed
`protected static TreeModel` | `createTreeModel(java.lang.Object value)` Returns a TreeModel wrapping the specified object.
`void` | `expandPath(TreePath path)` Ensures that the node identified by the specified path is expanded and viewable.
`TreeModel` | `getModel()` Returns the TreeModel that is providing the data.
`TreePath` | `getPathForRow(int row)` Returns the path for the specified row.
`int` | `getRowCount()` Returns the number of rows that are currently being displayed.
`TreeSelectionModel` | `getSelectionModel()` Returns the model for selections.
`TreePath` | `getSelectionPath()` Returns the path to the first selected node.
`int` | `getVisibleRowCount()` Returns the maximum number of rows that are displayed in the display area.
`boolean` | `isPathSelected(TreePath path)` Returns true if the item identified by the path is currently selected.
`boolean` | `isRootVisible()` Returns true if the root node of the tree is displayed.
`boolean` | `isSelectionEmpty()` Returns true if the selection is currently empty.
`boolean` | `isVisible(TreePath path)` Returns true if the value identified by path is currently viewable, which means it is either the root or all of its parents are expanded.
`void` | `makeVisible(TreePath path)` Ensures that the node identified by path is currently viewable.
`void` | `removeSelectionPath(TreePath path)` Removes the node identified by the specified path from the current selection.
`void` | `removeSelectionRow(int row)` Removes the row at the index row from the current selection.
`void` | `scrollPathToVisible(TreePath path)` Makes sure all the path components in path are expanded (except for the last path component) and scrolls so that the node identified by the path is displayed.
`void` | `scrollRowToVisible(int row)` Scrolls the item identified by row until it is displayed.
`void` | `setModel(TreeModel newModel_)` Sets the TreeModel that will provide the data.
`void` | `setRootVisible(boolean rootVisible)` Determines whether or not the root node from the TreeModel is visible.
`void` | `setSelectionModel(TreeSelectionModel selectionModel)` Sets the tree's selection model.
`void` | `setSelectionPath(TreePath path)` Selects the node identified by the specified path.
`void` | `setSelectionRow(int row)` Selects the node at the specified row in the display.
`void` | `setVisibleRowCount(int newCount)` Sets the number of rows that are to be displayed.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _treeModel

    protected TreeModel _treeModel

### _selectionModel

    protected TreeSelectionModel _selectionModel

### _visibleRowCount

    protected int _visibleRowCount

Constructor Detail

### JTree

    public JTree(TreeNode root)

  Returns a JTree with the specified TreeNode as its root, which displays the root node. By default, the tree defines a leaf node as any node without children.

### JTree

    public JTree(TreeNode root,
                 boolean asksAllowsChildren)

  Returns a JTree with the specified TreeNode as its root, which displays the root node and which decides whether a node is a leaf node in the specified manner.

Parameters:
  `root` - a TreeNode object
  `asksAllowsChildren` - if false, any node without children is a leaf node; if true, only nodes that do not allow children are leaf nodes

Method Detail

### getModel

    public TreeModel getModel()

  Returns the TreeModel that is providing the data.

### setModel

    public void setModel(TreeModel newModel_)

  Sets the TreeModel that will provide the data.

### isRootVisible

    public boolean isRootVisible()

  Returns true if the root node of the tree is displayed.

  Returns:
    true if the root node of the tree is displayed

### setRootVisible

    public void setRootVisible(boolean rootVisible)

  Determines whether or not the root node from the TreeModel is visible.

  Parameters:
    `rootVisible` - true if the root node of the tree is to be displayed

### getRowCount

    public int getRowCount()

  Returns the number of rows that are currently being displayed.

### setSelectionPath

    public void setSelectionPath(TreePath path)

  Selects the node identified by the specified path. If any component of the path is hidden (under a collapsed node), and getExpandsSelectedPaths is true it is exposed (made viewable).

### setSelectionRow

    public void setSelectionRow(int row)

  Selects the node at the specified row in the display.

### getSelectionPath

    public TreePath getSelectionPath()

  Returns the path to the first selected node.

  Returns:
    the TreePath for the first selected node, or null if nothing is currently selected

### isPathSelected

    public boolean isPathSelected(TreePath path)

  Returns true if the item identified by the path is currently selected.

### makeVisible

    public void makeVisible(TreePath path)

  Ensures that the node identified by path is currently viewable.

### isVisible

    public boolean isVisible(TreePath path)

  Returns true if the value identified by path is currently viewable, which means it is either the root or all of its parents are expanded. Otherwise, this method returns false.

### scrollPathToVisible

    public void scrollPathToVisible(TreePath path)

  Makes sure all the path components in path are expanded (except for the last path component) and scrolls so that the node identified by the path is displayed. Only works when this JTree is contained in a JScrollPane.

### scrollRowToVisible

    public void scrollRowToVisible(int row)

  Scrolls the item identified by row until it is displayed. The minimum of amount of scrolling necessary to bring the row into view is performed. Only works when this JTree is contained in a JScrollPane.

  Parameters:
    `row` - an integer specifying the row to scroll, where 0 is the first row in the display

### getPathForRow

    public TreePath getPathForRow(int row)

  Returns the path for the specified row. If row is not visible, null is returned.

  Returns:
    the TreePath to the specified node, null if row < 0 or row > getRowCount().

### expandPath

    public void expandPath(TreePath path)

  Ensures that the node identified by the specified path is expanded and viewable. If the last item in the path is a leaf, this will have no effect.

### collapsePath

    public void collapsePath(TreePath path)

  Ensures that the node identified by the specified path is collapsed

### setSelectionModel

    public void setSelectionModel(TreeSelectionModel selectionModel)

  Sets the tree's selection model. When a null value is specified an empty selectionModel is used, which does not allow selections.

### getSelectionModel

    public TreeSelectionModel getSelectionModel()

  Returns the model for selections. This should always return a non-null value. If you don't want to allow anything to be selected set the selection model to null, which forces an empty selection model to be used.

### removeSelectionPath

    public void removeSelectionPath(TreePath path)

  Removes the node identified by the specified path from the current selection.

### removeSelectionRow

    public void removeSelectionRow(int row)

  Removes the row at the index row from the current selection.

### clearSelection

    public void clearSelection()

  Clears the selection.

### isSelectionEmpty

    public boolean isSelectionEmpty()

  Returns true if the selection is currently empty.

### setVisibleRowCount

    public void setVisibleRowCount(int newCount)

  Sets the number of rows that are to be displayed. This will only work if the tree is contained in a JScrollPane, and will adjust the preferred size and size of that scrollpane.

### getVisibleRowCount

    public int getVisibleRowCount()

  Returns the maximum number of rows that are displayed in the display area.

### createTreeModel

    protected static TreeModel createTreeModel(java.lang.Object value)

  Returns a TreeModel wrapping the specified object.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD