javax.swing

Class JTree

public class JTree extends JComponent implements Scrollable, Accessible

Nested Class Summary
protected classJTree.AccessibleJTree
This class implements accessibility support for the JTree class.
static classJTree.DynamicUtilTreeNode
protected static classJTree.EmptySelectionModel
A TreeModel that does not allow anything to be selected.
protected classJTree.TreeModelHandler
Listens to the model of the JTree and updates the property expandedState if nodes are removed or changed.
protected classJTree.TreeSelectionRedirector
This redirects TreeSelectionEvents and rewrites the source of it to be this JTree.
Field Summary
static StringANCHOR_SELECTION_PATH_PROPERTY
protected TreeCellEditorcellEditor
protected TreeCellRenderercellRenderer
static StringCELL_EDITOR_PROPERTY
static StringCELL_RENDERER_PROPERTY
protected booleaneditable
static StringEDITABLE_PROPERTY
static StringEXPANDS_SELECTED_PATHS_PROPERTY
protected booleaninvokesStopCellEditing
static StringINVOKES_STOP_CELL_EDITING_PROPERTY
protected booleanlargeModel
static StringLARGE_MODEL_PROPERTY
static StringLEAD_SELECTION_PATH_PROPERTY
protected booleanrootVisible
protected introwHeight
static StringROOT_VISIBLE_PROPERTY
static StringROW_HEIGHT_PROPERTY
protected booleanscrollsOnExpand
protected TreeSelectionModelselectionModel
protected JTree.TreeSelectionRedirectorselectionRedirector
Redirects TreeSelectionEvents so that the source is this JTree.
protected booleanshowsRootHandles
static StringSCROLLS_ON_EXPAND_PROPERTY
static StringSELECTION_MODEL_PROPERTY
static StringSHOWS_ROOT_HANDLES_PROPERTY
protected inttoggleClickCount
protected TreeModeltreeModel
protected TreeModelListenertreeModelListener
Handles TreeModelEvents to update the expandedState.
static StringTOGGLE_CLICK_COUNT_PROPERTY
static StringTREE_MODEL_PROPERTY
protected intvisibleRowCount
static StringVISIBLE_ROW_COUNT_PROPERTY
Constructor Summary
JTree()
Creates a new JTree object.
JTree(Hashtable<?,?> value)
Creates a new JTree object.
JTree(Object[] value)
Creates a new JTree object.
JTree(TreeModel model)
Creates a new JTree object.
JTree(TreeNode root)
Creates a new JTree object.
JTree(TreeNode root, boolean asksAllowChildren)
Creates a new JTree object.
JTree(Vector<?> value)
Creates a new JTree object.
Method Summary
voidaddSelectionInterval(int index0, int index1)
Select all rows between the two given indexes, inclusive.
voidaddSelectionPath(TreePath path)
voidaddSelectionPaths(TreePath[] paths)
voidaddSelectionRow(int row)
voidaddSelectionRows(int[] rows)
voidaddTreeExpansionListener(TreeExpansionListener listener)
Adds a TreeExpansionListener object to the tree.
voidaddTreeSelectionListener(TreeSelectionListener listener)
Adds a TreeSelctionListener object to the tree.
voidaddTreeWillExpandListener(TreeWillExpandListener listener)
Adds a TreeWillExpandListener object to the tree.
voidcancelEditing()
voidclearSelection()
protected voidclearToggledPaths()
voidcollapsePath(TreePath path)
voidcollapseRow(int row)
StringconvertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
Converts the specified value to a String.
protected static TreeModelcreateTreeModel(Object value)
Creates a new TreeModel object.
protected TreeModelListenercreateTreeModelListener()
Creates and returns an instance of {@link TreeModelHandler}.
voidexpandPath(TreePath path)
voidexpandRow(int row)
voidfireTreeCollapsed(TreePath path)
Notifies all listeners that the tree was collapsed.
voidfireTreeExpanded(TreePath path)
Notifies all listeners that the tree was expanded.
voidfireTreeWillCollapse(TreePath path)
Notifies all listeners that the tree will collapse.
voidfireTreeWillExpand(TreePath path)
Notifies all listeners that the tree will expand.
protected voidfireValueChanged(TreeSelectionEvent event)
Notifies all listeners when the selection of the tree changed.
AccessibleContextgetAccessibleContext()
Gets the AccessibleContext associated with this JTree.
TreePathgetAnchorSelectionPath()
TreeCellEditorgetCellEditor()
TreeCellRenderergetCellRenderer()
TreePathgetClosestPathForLocation(int x, int y)
intgetClosestRowForLocation(int x, int y)
protected static TreeModelgetDefaultTreeModel()
Returns a sample TreeModel that can be used in a JTree.
protected Enumeration<TreePath>getDescendantToggledPaths(TreePath parent)
booleangetDragEnabled()
Return the value of the dragEnabled property.
TreePathgetEditingPath()
Enumeration<TreePath>getExpandedDescendants(TreePath path)
Returns all TreePath objects which are a descendants of the given path and are exapanded at the moment of the execution of this method.
booleangetExpandsSelectedPaths()
booleangetInvokesStopCellEditing()
ObjectgetLastSelectedPathComponent()
TreePathgetLeadSelectionPath()
intgetLeadSelectionRow()
intgetMaxSelectionRow()
intgetMinSelectionRow()
TreeModelgetModel()
Returns the model of this JTree object.
TreePathgetNextMatch(String prefix, int startingRow, Position.Bias bias)
Returns the next table element (beginning from the row startingRow that starts with prefix.
protected TreePath[]getPathBetweenRows(int index0, int index1)
Get the pathes that are displayes between the two given rows.
RectanglegetPathBounds(TreePath path)
TreePathgetPathForLocation(int x, int y)
TreePathgetPathForRow(int row)
DimensiongetPreferredScrollableViewportSize()
Returns the preferred viewport size.
RectanglegetRowBounds(int row)
intgetRowCount()
intgetRowForLocation(int x, int y)
intgetRowForPath(TreePath path)
intgetRowHeight()
intgetScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
booleangetScrollableTracksViewportHeight()
booleangetScrollableTracksViewportWidth()
intgetScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
Return the preferred scrolling amount (in pixels) for the given scrolling direction and orientation.
booleangetScrollsOnExpand()
intgetSelectionCount()
TreeSelectionModelgetSelectionModel()
TreePathgetSelectionPath()
TreePath[]getSelectionPaths()
int[]getSelectionRows()
booleangetShowsRootHandles()
intgetToggleClickCount()
TreeExpansionListener[]getTreeExpansionListeners()
Returns all added TreeExpansionListener objects.
TreeSelectionListener[]getTreeSelectionListeners()
Returns all added TreeSelectionListener objects.
TreeWillExpandListener[]getTreeWillExpandListeners()
Returns all added TreeWillExpandListener objects.
TreeUIgetUI()
Return the UI associated with this JTree object.
StringgetUIClassID()
This method returns the String ID of the UI class of Separator.
intgetVisibleRowCount()
booleanhasBeenExpanded(TreePath path)
booleanisCollapsed(TreePath path)
booleanisCollapsed(int row)
booleanisEditable()
Checks if this JTree object is editable.
booleanisEditing()
booleanisExpanded(TreePath path)
booleanisExpanded(int row)
booleanisFixedRowHeight()
booleanisLargeModel()
booleanisPathEditable(TreePath path)
booleanisPathSelected(TreePath path)
booleanisRootVisible()
Checks if the root element is visible.
booleanisRowSelected(int row)
Returns true when the specified row is selected, false otherwise.
booleanisSelectionEmpty()
booleanisVisible(TreePath path)
voidmakeVisible(TreePath path)
protected StringparamString()
A String representation of this JTree.
protected booleanremoveDescendantSelectedPaths(TreePath path, boolean includeSelected)
Removes any paths in the current set of selected paths that are descendants of path.
protected voidremoveDescendantToggledPaths(Enumeration<TreePath> toRemove)
Removes any descendants of the TreePaths in toRemove that have been expanded.
voidremoveSelectionInterval(int index0, int index1)
voidremoveSelectionPath(TreePath path)
voidremoveSelectionPaths(TreePath[] paths)
voidremoveSelectionRow(int row)
voidremoveSelectionRows(int[] rows)
voidremoveTreeExpansionListener(TreeExpansionListener listener)
Removes a TreeExpansionListener object from the tree.
voidremoveTreeSelectionListener(TreeSelectionListener listener)
Removes a TreeSelectionListener object from the tree.
voidremoveTreeWillExpandListener(TreeWillExpandListener listener)
Removes a TreeWillExpandListener object from the tree.
voidscrollPathToVisible(TreePath path)
voidscrollRowToVisible(int row)
voidsetAnchorSelectionPath(TreePath path)
voidsetCellEditor(TreeCellEditor editor)
voidsetCellRenderer(TreeCellRenderer newRenderer)
voidsetDragEnabled(boolean enabled)
Set the dragEnabled property.
voidsetEditable(boolean flag)
Sets the editable property.
protected voidsetExpandedState(TreePath path, boolean state)
voidsetExpandsSelectedPaths(boolean flag)
voidsetInvokesStopCellEditing(boolean invoke)
voidsetLargeModel(boolean large)
voidsetLeadSelectionPath(TreePath path)
voidsetModel(TreeModel model)
Sets the model to use in JTree.
voidsetRootVisible(boolean flag)
voidsetRowHeight(int height)
voidsetScrollsOnExpand(boolean scroll)
voidsetSelectionInterval(int index0, int index1)
voidsetSelectionModel(TreeSelectionModel model)
voidsetSelectionPath(TreePath path)
voidsetSelectionPaths(TreePath[] paths)
voidsetSelectionRow(int row)
voidsetSelectionRows(int[] rows)
voidsetShowsRootHandles(boolean flag)
voidsetToggleClickCount(int count)
voidsetUI(TreeUI ui)
Sets the UI associated with this JTree object.
voidsetVisibleRowCount(int rows)
voidstartEditingAtPath(TreePath path)
booleanstopEditing()
voidtreeDidChange()

Sent when the tree has changed enough that we need to resize the bounds, but not enough that we need to remove the expanded node set (e.g nodes were expanded or collapsed, or nodes were inserted into the tree).

voidupdateUI()
This method resets the UI used to the Look and Feel defaults..

Field Detail

ANCHOR_SELECTION_PATH_PROPERTY

public static final String ANCHOR_SELECTION_PATH_PROPERTY

Since: 1.3

cellEditor

protected transient TreeCellEditor cellEditor

cellRenderer

protected transient TreeCellRenderer cellRenderer

CELL_EDITOR_PROPERTY

public static final String CELL_EDITOR_PROPERTY

CELL_RENDERER_PROPERTY

public static final String CELL_RENDERER_PROPERTY

editable

protected boolean editable

EDITABLE_PROPERTY

public static final String EDITABLE_PROPERTY

EXPANDS_SELECTED_PATHS_PROPERTY

public static final String EXPANDS_SELECTED_PATHS_PROPERTY

Since: 1.3

invokesStopCellEditing

protected boolean invokesStopCellEditing

INVOKES_STOP_CELL_EDITING_PROPERTY

public static final String INVOKES_STOP_CELL_EDITING_PROPERTY

largeModel

protected boolean largeModel

LARGE_MODEL_PROPERTY

public static final String LARGE_MODEL_PROPERTY

LEAD_SELECTION_PATH_PROPERTY

public static final String LEAD_SELECTION_PATH_PROPERTY

Since: 1.3

rootVisible

protected boolean rootVisible

rowHeight

protected int rowHeight

ROOT_VISIBLE_PROPERTY

public static final String ROOT_VISIBLE_PROPERTY

ROW_HEIGHT_PROPERTY

public static final String ROW_HEIGHT_PROPERTY

scrollsOnExpand

protected boolean scrollsOnExpand

selectionModel

protected transient TreeSelectionModel selectionModel

selectionRedirector

protected JTree.TreeSelectionRedirector selectionRedirector
Redirects TreeSelectionEvents so that the source is this JTree.

showsRootHandles

protected boolean showsRootHandles

SCROLLS_ON_EXPAND_PROPERTY

public static final String SCROLLS_ON_EXPAND_PROPERTY

SELECTION_MODEL_PROPERTY

public static final String SELECTION_MODEL_PROPERTY

SHOWS_ROOT_HANDLES_PROPERTY

public static final String SHOWS_ROOT_HANDLES_PROPERTY

toggleClickCount

protected int toggleClickCount

treeModel

protected transient TreeModel treeModel

treeModelListener

protected transient TreeModelListener treeModelListener
Handles TreeModelEvents to update the expandedState.

TOGGLE_CLICK_COUNT_PROPERTY

public static final String TOGGLE_CLICK_COUNT_PROPERTY

TREE_MODEL_PROPERTY

public static final String TREE_MODEL_PROPERTY

visibleRowCount

protected int visibleRowCount

VISIBLE_ROW_COUNT_PROPERTY

public static final String VISIBLE_ROW_COUNT_PROPERTY

Constructor Detail

JTree

public JTree()
Creates a new JTree object.

JTree

public JTree(Hashtable<?,?> value)
Creates a new JTree object.

Parameters: value the initial nodes in the tree

JTree

public JTree(Object[] value)
Creates a new JTree object.

Parameters: value the initial nodes in the tree

JTree

public JTree(TreeModel model)
Creates a new JTree object.

Parameters: model the model to use

JTree

public JTree(TreeNode root)
Creates a new JTree object.

Parameters: root the root node

JTree

public JTree(TreeNode root, boolean asksAllowChildren)
Creates a new JTree object.

Parameters: root the root node asksAllowChildren if false, all nodes without children are leaf nodes. If true, only nodes that do not allow children are leaf nodes.

JTree

public JTree(Vector<?> value)
Creates a new JTree object.

Parameters: value the initial nodes in the tree

Method Detail

addSelectionInterval

public void addSelectionInterval(int index0, int index1)
Select all rows between the two given indexes, inclusive. The method will not select the inner leaves and braches of the currently collapsed nodes in this interval.

Parameters: index0 the starting row, inclusive index1 the ending row, inclusive

addSelectionPath

public void addSelectionPath(TreePath path)

addSelectionPaths

public void addSelectionPaths(TreePath[] paths)

addSelectionRow

public void addSelectionRow(int row)

addSelectionRows

public void addSelectionRows(int[] rows)

addTreeExpansionListener

public void addTreeExpansionListener(TreeExpansionListener listener)
Adds a TreeExpansionListener object to the tree.

Parameters: listener the listener to add

addTreeSelectionListener

public void addTreeSelectionListener(TreeSelectionListener listener)
Adds a TreeSelctionListener object to the tree.

Parameters: listener the listener to add

addTreeWillExpandListener

public void addTreeWillExpandListener(TreeWillExpandListener listener)
Adds a TreeWillExpandListener object to the tree.

Parameters: listener the listener to add

cancelEditing

public void cancelEditing()

clearSelection

public void clearSelection()

clearToggledPaths

protected void clearToggledPaths()

collapsePath

public void collapsePath(TreePath path)

collapseRow

public void collapseRow(int row)

convertValueToText

public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
Converts the specified value to a String. This is used by the renderers of this JTree and its nodes. This implementation simply returns value.toString() and ignores all other parameters. Subclass this method to control the conversion.

Parameters: value the value that is converted to a String selected indicates if that value is selected or not expanded indicates if that value is expanded or not leaf indicates if that value is a leaf node or not row the row of the node hasFocus indicates if that node has focus or not

createTreeModel

protected static TreeModel createTreeModel(Object value)
Creates a new TreeModel object.

Parameters: value the values stored in the model

createTreeModelListener

protected TreeModelListener createTreeModelListener()
Creates and returns an instance of {@link TreeModelHandler}.

Returns: an instance of {@link TreeModelHandler}

expandPath

public void expandPath(TreePath path)

expandRow

public void expandRow(int row)

fireTreeCollapsed

public void fireTreeCollapsed(TreePath path)
Notifies all listeners that the tree was collapsed.

Parameters: path the path to the node that was collapsed

fireTreeExpanded

public void fireTreeExpanded(TreePath path)
Notifies all listeners that the tree was expanded.

Parameters: path the path to the node that was expanded

fireTreeWillCollapse

public void fireTreeWillCollapse(TreePath path)
Notifies all listeners that the tree will collapse.

Parameters: path the path to the node that will collapse

fireTreeWillExpand

public void fireTreeWillExpand(TreePath path)
Notifies all listeners that the tree will expand.

Parameters: path the path to the node that will expand

fireValueChanged

protected void fireValueChanged(TreeSelectionEvent event)
Notifies all listeners when the selection of the tree changed.

Parameters: event the event to send

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JTree.

Returns: the associated context

getAnchorSelectionPath

public TreePath getAnchorSelectionPath()

Since: 1.3

getCellEditor

public TreeCellEditor getCellEditor()

getCellRenderer

public TreeCellRenderer getCellRenderer()

getClosestPathForLocation

public TreePath getClosestPathForLocation(int x, int y)

getClosestRowForLocation

public int getClosestRowForLocation(int x, int y)

getDefaultTreeModel

protected static TreeModel getDefaultTreeModel()
Returns a sample TreeModel that can be used in a JTree. This can be used in Bean- or GUI-Builders to show something interesting.

Returns: a sample TreeModel that can be used in a JTree

getDescendantToggledPaths

protected Enumeration<TreePath> getDescendantToggledPaths(TreePath parent)

getDragEnabled

public boolean getDragEnabled()
Return the value of the dragEnabled property.

Returns: the value

Since: 1.4

getEditingPath

public TreePath getEditingPath()

getExpandedDescendants

public Enumeration<TreePath> getExpandedDescendants(TreePath path)
Returns all TreePath objects which are a descendants of the given path and are exapanded at the moment of the execution of this method. If the state of any node is beeing toggled while this method is executing this change may be left unaccounted.

Parameters: path The parent of this request

Returns: An Enumeration containing TreePath objects

getExpandsSelectedPaths

public boolean getExpandsSelectedPaths()

Since: 1.3

getInvokesStopCellEditing

public boolean getInvokesStopCellEditing()

getLastSelectedPathComponent

public Object getLastSelectedPathComponent()

getLeadSelectionPath

public TreePath getLeadSelectionPath()

getLeadSelectionRow

public int getLeadSelectionRow()

getMaxSelectionRow

public int getMaxSelectionRow()

getMinSelectionRow

public int getMinSelectionRow()

getModel

public TreeModel getModel()
Returns the model of this JTree object.

Returns: the associated TreeModel

getNextMatch

public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias)
Returns the next table element (beginning from the row startingRow that starts with prefix. Searching is done in the direction specified by bias.

Parameters: prefix the prefix to search for in the cell values startingRow the index of the row where to start searching from bias the search direction, either {@link Position.Bias#Forward} or {@link Position.Bias#Backward}

Returns: the path to the found element or -1 if no such element has been found

Throws: IllegalArgumentException if prefix is null or startingRow is not valid

Since: 1.4

getPathBetweenRows

protected TreePath[] getPathBetweenRows(int index0, int index1)
Get the pathes that are displayes between the two given rows.

Parameters: index0 the starting row, inclusive index1 the ending row, inclusive

Returns: the array of the tree pathes

getPathBounds

public Rectangle getPathBounds(TreePath path)

getPathForLocation

public TreePath getPathForLocation(int x, int y)

getPathForRow

public TreePath getPathForRow(int row)

getPreferredScrollableViewportSize

public Dimension getPreferredScrollableViewportSize()
Returns the preferred viewport size.

Returns: the preferred size

getRowBounds

public Rectangle getRowBounds(int row)

getRowCount

public int getRowCount()

getRowForLocation

public int getRowForLocation(int x, int y)

getRowForPath

public int getRowForPath(TreePath path)

getRowHeight

public int getRowHeight()

getScrollableBlockIncrement

public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()

getScrollableUnitIncrement

public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
Return the preferred scrolling amount (in pixels) for the given scrolling direction and orientation. This method handles a partially exposed row by returning the distance required to completely expose the item.

Parameters: visibleRect the currently visible part of the component. orientation the scrolling orientation direction the scrolling direction (negative - up, positive -down). The values greater than one means that more mouse wheel or similar events were generated, and hence it is better to scroll the longer distance.

getScrollsOnExpand

public boolean getScrollsOnExpand()

getSelectionCount

public int getSelectionCount()

getSelectionModel

public TreeSelectionModel getSelectionModel()

getSelectionPath

public TreePath getSelectionPath()

getSelectionPaths

public TreePath[] getSelectionPaths()

getSelectionRows

public int[] getSelectionRows()

getShowsRootHandles

public boolean getShowsRootHandles()

getToggleClickCount

public int getToggleClickCount()

Since: 1.3

getTreeExpansionListeners

public TreeExpansionListener[] getTreeExpansionListeners()
Returns all added TreeExpansionListener objects.

Returns: an array of listeners

getTreeSelectionListeners

public TreeSelectionListener[] getTreeSelectionListeners()
Returns all added TreeSelectionListener objects.

Returns: an array of listeners

getTreeWillExpandListeners

public TreeWillExpandListener[] getTreeWillExpandListeners()
Returns all added TreeWillExpandListener objects.

Returns: an array of listeners

getUI

public TreeUI getUI()
Return the UI associated with this JTree object.

Returns: the associated TreeUI object

getUIClassID

public String getUIClassID()
This method returns the String ID of the UI class of Separator.

Returns: The UI class' String ID.

getVisibleRowCount

public int getVisibleRowCount()

hasBeenExpanded

public boolean hasBeenExpanded(TreePath path)

isCollapsed

public boolean isCollapsed(TreePath path)

isCollapsed

public boolean isCollapsed(int row)

isEditable

public boolean isEditable()
Checks if this JTree object is editable.

Returns: true if this tree object is editable, false otherwise

isEditing

public boolean isEditing()

isExpanded

public boolean isExpanded(TreePath path)

isExpanded

public boolean isExpanded(int row)

isFixedRowHeight

public boolean isFixedRowHeight()

isLargeModel

public boolean isLargeModel()

isPathEditable

public boolean isPathEditable(TreePath path)

isPathSelected

public boolean isPathSelected(TreePath path)

isRootVisible

public boolean isRootVisible()
Checks if the root element is visible.

Returns: true if the root element is visible, false otherwise

isRowSelected

public boolean isRowSelected(int row)
Returns true when the specified row is selected, false otherwise. This call is delegated to the {@link TreeSelectionModel#isRowSelected(int)} method.

Parameters: row the row to check

Returns: true when the specified row is selected, false otherwise

isSelectionEmpty

public boolean isSelectionEmpty()

isVisible

public boolean isVisible(TreePath path)

makeVisible

public void makeVisible(TreePath path)

paramString

protected String paramString()
A String representation of this JTree. This is intended to be used for debugging. The returned string may be empty but may not be null.

Returns: a String representation of this JTree

removeDescendantSelectedPaths

protected boolean removeDescendantSelectedPaths(TreePath path, boolean includeSelected)
Removes any paths in the current set of selected paths that are descendants of path. If includePath is set to true and path itself is selected, then it will be removed too.

Parameters: path the path from which selected descendants are to be removed includeSelected if true then path itself will also be remove if it's selected

Returns: true if something has been removed, false otherwise

Since: 1.3

removeDescendantToggledPaths

protected void removeDescendantToggledPaths(Enumeration<TreePath> toRemove)
Removes any descendants of the TreePaths in toRemove that have been expanded.

Parameters: toRemove - Enumeration of TreePaths that need to be removed from cache of toggled tree paths.

removeSelectionInterval

public void removeSelectionInterval(int index0, int index1)

removeSelectionPath

public void removeSelectionPath(TreePath path)

removeSelectionPaths

public void removeSelectionPaths(TreePath[] paths)

removeSelectionRow

public void removeSelectionRow(int row)

removeSelectionRows

public void removeSelectionRows(int[] rows)

removeTreeExpansionListener

public void removeTreeExpansionListener(TreeExpansionListener listener)
Removes a TreeExpansionListener object from the tree.

Parameters: listener the listener to remove

removeTreeSelectionListener

public void removeTreeSelectionListener(TreeSelectionListener listener)
Removes a TreeSelectionListener object from the tree.

Parameters: listener the listener to remove

removeTreeWillExpandListener

public void removeTreeWillExpandListener(TreeWillExpandListener listener)
Removes a TreeWillExpandListener object from the tree.

Parameters: listener the listener to remove

scrollPathToVisible

public void scrollPathToVisible(TreePath path)

scrollRowToVisible

public void scrollRowToVisible(int row)

setAnchorSelectionPath

public void setAnchorSelectionPath(TreePath path)

Since: 1.3

setCellEditor

public void setCellEditor(TreeCellEditor editor)

setCellRenderer

public void setCellRenderer(TreeCellRenderer newRenderer)

setDragEnabled

public void setDragEnabled(boolean enabled)
Set the dragEnabled property.

Parameters: enabled new value

Since: 1.4

setEditable

public void setEditable(boolean flag)
Sets the editable property.

Parameters: flag true to make this tree object editable, false otherwise

setExpandedState

protected void setExpandedState(TreePath path, boolean state)

setExpandsSelectedPaths

public void setExpandsSelectedPaths(boolean flag)

Since: 1.3

setInvokesStopCellEditing

public void setInvokesStopCellEditing(boolean invoke)

setLargeModel

public void setLargeModel(boolean large)

setLeadSelectionPath

public void setLeadSelectionPath(TreePath path)

Since: 1.3

setModel

public void setModel(TreeModel model)
Sets the model to use in JTree.

Parameters: model the TreeModel to use

setRootVisible

public void setRootVisible(boolean flag)

setRowHeight

public void setRowHeight(int height)

setScrollsOnExpand

public void setScrollsOnExpand(boolean scroll)

setSelectionInterval

public void setSelectionInterval(int index0, int index1)

setSelectionModel

public void setSelectionModel(TreeSelectionModel model)

setSelectionPath

public void setSelectionPath(TreePath path)

setSelectionPaths

public void setSelectionPaths(TreePath[] paths)

setSelectionRow

public void setSelectionRow(int row)

setSelectionRows

public void setSelectionRows(int[] rows)

setShowsRootHandles

public void setShowsRootHandles(boolean flag)

setToggleClickCount

public void setToggleClickCount(int count)

Since: 1.3

setUI

public void setUI(TreeUI ui)
Sets the UI associated with this JTree object.

Parameters: ui the TreeUI to associate

setVisibleRowCount

public void setVisibleRowCount(int rows)

startEditingAtPath

public void startEditingAtPath(TreePath path)

stopEditing

public boolean stopEditing()

treeDidChange

public void treeDidChange()

Sent when the tree has changed enough that we need to resize the bounds, but not enough that we need to remove the expanded node set (e.g nodes were expanded or collapsed, or nodes were inserted into the tree). You should never have to invoke this, the UI will invoke this as it needs to.

If the tree uses {@link DefaultTreeModel}, you must call {@link DefaultTreeModel#reload(TreeNode)} or {@link DefaultTreeModel#reload()} after adding or removing nodes. Following the official Java 1.5 API standard, just calling treeDidChange, repaint() or revalidate() does not update the tree appearance properly.

See Also: reload

updateUI

public void updateUI()
This method resets the UI used to the Look and Feel defaults..