clearSelection
public void clearSelection()
Clears the selection.
collapsePath
public void collapsePath(TreePath path)
Ensures that the node identified by the specified path is collapsed
createTreeModel
protected static TreeModel createTreeModel(Object value)
Returns a TreeModel wrapping the specified object.
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.
getModel
public TreeModel getModel()
Returns the TreeModel that is providing the data.
getPathForRow
public TreePath getPathForRow(int row)
Returns the path for the specified row. If row is not visible,
null is returned.
- the TreePath to the specified node, null if row < 0 or row
> getRowCount().
getRowCount
public int getRowCount()
Returns the number of rows that are currently being displayed.
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.
getSelectionPath
public TreePath getSelectionPath()
Returns the path to the first selected node.
- the TreePath for the first selected node, or null if nothing is
currently selected
getVisibleRowCount
public int getVisibleRowCount()
Returns the maximum number of rows that are displayed in the
display area.
isPathSelected
public boolean isPathSelected(TreePath path)
Returns true if the item identified by the path is currently selected.
isRootVisible
public boolean isRootVisible()
Returns true if the root node of the tree is displayed.
- true if the root node of the tree is displayed
isSelectionEmpty
public boolean isSelectionEmpty()
Returns true if the selection is currently empty.
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.
makeVisible
public void makeVisible(TreePath path)
Ensures that the node identified by path is currently viewable.
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.
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.
row
- an integer specifying the row to scroll, where 0 is the
first row in the display
setModel
public void setModel(TreeModel newModel_)
Sets the TreeModel that will provide the data.
setRootVisible
public void setRootVisible(boolean rootVisible)
Determines whether or not the root node from the TreeModel is visible.
rootVisible
- true if the root node of the tree is to be
displayed
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.
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.
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.