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.
index0
- the starting row, inclusiveindex1
- the ending row, inclusive
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.
value
- the value that is converted to a Stringselected
- indicates if that value is selected or notexpanded
- indicates if that value is expanded or notleaf
- indicates if that value is a leaf node or notrow
- the row of the nodehasFocus
- indicates if that node has focus or not
fireTreeCollapsed
public void fireTreeCollapsed(TreePath path)
Notifies all listeners that the tree was collapsed.
path
- the path to the node that was collapsed
fireTreeExpanded
public void fireTreeExpanded(TreePath path)
Notifies all listeners that the tree was expanded.
path
- the path to the node that was expanded
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.
- a sample TreeModel that can be used in a JTree
getDragEnabled
public boolean getDragEnabled()
Return the value of the dragEnabled
property.
getExpandedDescendants
public Enumeration 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.
path
- The parent of this request
- An Enumeration containing TreePath objects
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
.
- the path to the found element or -1 if no such element has been
found
getPathBetweenRows
protected TreePath[] getPathBetweenRows(int index0,
int index1)
Get the pathes that are displayes between the two given rows.
index0
- the starting row, inclusiveindex1
- the ending row, inclusive
- the array of the tree pathes
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.
- getScrollableUnitIncrement in interface Scrollable
visibleRect
- the currently visible part of the component.orientation
- the scrolling orientationdirection
- 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.
getUI
public TreeUI getUI()
Return the UI associated with this JTree
object.
- the associated
TreeUI
object
isEditable
public boolean isEditable()
Checks if this JTree
object is editable.
true
if this tree object is editable,
false
otherwise
isRootVisible
public boolean isRootVisible()
Checks if the root element is visible.
true
if the root element is visible,
false
otherwise
isRowSelected
public boolean isRowSelected(int row)
true
when the specified row is selected,
false
otherwise
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
.
- paramString in interface JComponent
- 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.
path
- the path from which selected descendants are to be removedincludeSelected
- if true
then path
itself
will also be remove if it's selected
true
if something has been removed,
false
otherwise
removeDescendantToggledPaths
protected void removeDescendantToggledPaths(Enumeration toRemove)
Removes any descendants of the TreePaths in toRemove that have been
expanded.
toRemove
- - Enumeration of TreePaths that need to be removed from
cache of toggled tree paths.
setDragEnabled
public void setDragEnabled(boolean enabled)
Set the dragEnabled
property.
setEditable
public void setEditable(boolean flag)
Sets the editable
property.
flag
- true
to make this tree object editable,
false
otherwise
setModel
public void setModel(TreeModel model)
Sets the model to use in JTree
.
model
- the TreeModel
to use
setUI
public void setUI(TreeUI ui)
Sets the UI associated with this JTree
object.
ui
- the TreeUI
to associate
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
DefaultTreeModel
, you must call
DefaultTreeModel.reload(TreeNode)
or
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.
JTree.java
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.