Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
Nested Class Summary | |
protected class |
|
static class | |
protected static class |
|
protected class |
|
protected class |
|
Nested classes/interfaces inherited from class javax.swing.JComponent | |
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container | |
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component | |
Component.AccessibleAWTComponent , Component.BltBufferStrategy , Component.FlipBufferStrategy |
Field Summary | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
protected TreeCellEditor | |
protected TreeCellRenderer | |
protected boolean | |
protected boolean | |
protected boolean | |
protected boolean | |
protected int | |
protected boolean | |
protected TreeSelectionModel | |
protected JTree.TreeSelectionRedirector |
|
protected boolean | |
protected int | |
protected TreeModel | |
protected TreeModelListener |
|
protected int |
Fields inherited from class javax.swing.JComponent | |
TOOL_TIP_TEXT_KEY , UNDEFINED_CONDITION , WHEN_ANCESTOR_OF_FOCUSED_COMPONENT , WHEN_FOCUSED , WHEN_IN_FOCUSED_WINDOW , accessibleContext , listenerList , ui |
Fields inherited from class java.awt.Component | |
BOTTOM_ALIGNMENT , CENTER_ALIGNMENT , LEFT_ALIGNMENT , RIGHT_ALIGNMENT , TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver | |
ABORT , ALLBITS , ERROR , FRAMEBITS , HEIGHT , PROPERTIES , SOMEBITS , WIDTH |
Constructor Summary | |
| |
| |
| |
Method Summary | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void | |
protected void | |
void |
|
void |
|
String |
|
protected static TreeModel |
|
protected TreeModelListener |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
protected void |
|
AccessibleContext |
|
TreePath | |
TreeCellEditor | |
TreeCellRenderer | |
TreePath |
|
int |
|
protected static TreeModel |
|
protected Enumeration |
|
boolean |
|
TreePath | |
Enumeration |
|
boolean | |
boolean | |
Object | |
TreePath | |
int | |
int | |
int | |
TreeModel |
|
TreePath |
|
protected TreePath[] |
|
Rectangle |
|
TreePath |
|
TreePath |
|
Dimension |
|
Rectangle |
|
int | |
int |
|
int |
|
int | |
int |
|
boolean | |
boolean | |
int |
|
boolean | |
int | |
TreeSelectionModel | |
TreePath | |
TreePath[] | |
int[] | |
boolean | |
int | |
TreeExpansionListener[] |
|
TreeSelectionListener[] |
|
TreeWillExpandListener[] |
|
TreeUI |
|
String |
|
int | |
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean | |
boolean |
|
boolean |
|
boolean | |
boolean | |
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean | |
boolean | |
void |
|
protected String |
|
protected boolean |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
boolean | |
void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final String ANCHOR_SELECTION_PATH_PROPERTY
- Field Value:
- "anchorSelectionPath"
- Since:
- 1.3
public static final String EXPANDS_SELECTED_PATHS_PROPERTY
- Field Value:
- "expandsSelectedPaths"
- Since:
- 1.3
public static final String INVOKES_STOP_CELL_EDITING_PROPERTY
- Field Value:
- "invokesStopCellEditing"
public static final String LEAD_SELECTION_PATH_PROPERTY
- Field Value:
- "leadSelectionPath"
- Since:
- 1.3
public static final String SCROLLS_ON_EXPAND_PROPERTY
- Field Value:
- "scrollsOnExpand"
public static final String SELECTION_MODEL_PROPERTY
- Field Value:
- "selectionModel"
public static final String SHOWS_ROOT_HANDLES_PROPERTY
- Field Value:
- "showsRootHandles"
public static final String TOGGLE_CLICK_COUNT_PROPERTY
- Field Value:
- "toggleClickCount"
public static final String VISIBLE_ROW_COUNT_PROPERTY
- Field Value:
- "visibleRowCount"
protected JTree.TreeSelectionRedirector selectionRedirector
Redirects TreeSelectionEvents so that the source is this JTree.
protected TreeModelListener treeModelListener
Handles TreeModelEvents to update the expandedState.
public JTree(Hashtable value)
Creates a newJTree
object.
- Parameters:
value
- the initial nodes in the tree
public JTree(Vector value)
Creates a newJTree
object.
- Parameters:
value
- the initial nodes in the tree
public JTree(Object[] value)
Creates a newJTree
object.
- Parameters:
value
- the initial nodes in the tree
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, inclusiveindex1
- the ending row, inclusive
public void addTreeExpansionListener(TreeExpansionListener listener)
Adds aTreeExpansionListener
object to the tree.
- Parameters:
listener
- the listener to add
public void addTreeSelectionListener(TreeSelectionListener listener)
Adds aTreeSelctionListener
object to the tree.
- Parameters:
listener
- the listener to add
public void addTreeWillExpandListener(TreeWillExpandListener listener)
Adds aTreeWillExpandListener
object to the tree.
- Parameters:
listener
- the listener to add
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 returnsvalue.toString()
and ignores all other parameters. Subclass this method to control the conversion.
- Parameters:
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
protected static TreeModel createTreeModel(Object value)
Creates a newTreeModel
object.
- Parameters:
value
- the values stored in the model
protected TreeModelListener createTreeModelListener()
Creates and returns an instance ofJTree.TreeModelHandler
.
- Returns:
- an instance of
JTree.TreeModelHandler
public void fireTreeCollapsed(TreePath path)
Notifies all listeners that the tree was collapsed.
- Parameters:
path
- the path to the node that was collapsed
public void fireTreeExpanded(TreePath path)
Notifies all listeners that the tree was expanded.
- Parameters:
path
- the path to the node that was expanded
public void fireTreeWillCollapse(TreePath path) throws ExpandVetoException
Notifies all listeners that the tree will collapse.
- Parameters:
path
- the path to the node that will collapse
public void fireTreeWillExpand(TreePath path) throws ExpandVetoException
Notifies all listeners that the tree will expand.
- Parameters:
path
- the path to the node that will expand
protected void fireValueChanged(TreeSelectionEvent event)
Notifies all listeners when the selection of the tree changed.
- Parameters:
event
- the event to send
public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with thisJTree
.
- Specified by:
- getAccessibleContext in interface Accessible
- Overrides:
- getAccessibleContext in interface JComponent
- Returns:
- the associated context
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
public boolean getDragEnabled()
Return the value of thedragEnabled
property.
- Returns:
- the value
- Since:
- 1.4
public EnumerationgetExpandedDescendants(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
public TreeModel getModel()
Returns the model of thisJTree
object.
- Returns:
- the associated
TreeModel
public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias)
Returns the next table element (beginning from the rowstartingRow
that starts withprefix
. Searching is done in the direction specified bybias
.
- Parameters:
prefix
- the prefix to search for in the cell valuesstartingRow
- the index of the row where to start searching frombias
- the search direction, eitherPosition.Bias.Forward
orPosition.Bias.Backward
- Returns:
- the path to the found element or -1 if no such element has been found
- Throws:
IllegalArgumentException
- if prefix isnull
or startingRow is not valid
- Since:
- 1.4
protected TreePath[] getPathBetweenRows(int index0, int index1)
Get the pathes that are displayes between the two given rows.
- Parameters:
index0
- the starting row, inclusiveindex1
- the ending row, inclusive
- Returns:
- the array of the tree pathes
public Dimension getPreferredScrollableViewportSize()
Returns the preferred viewport size.
- Specified by:
- getPreferredScrollableViewportSize in interface Scrollable
- Returns:
- the preferred size
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
- Specified by:
- getScrollableBlockIncrement in interface Scrollable
public boolean getScrollableTracksViewportHeight()
- Specified by:
- getScrollableTracksViewportHeight in interface Scrollable
public boolean getScrollableTracksViewportWidth()
- Specified by:
- getScrollableTracksViewportWidth in interface Scrollable
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.
- Specified by:
- getScrollableUnitIncrement in interface Scrollable
- Parameters:
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.
public TreeExpansionListener[] getTreeExpansionListeners()
Returns all addedTreeExpansionListener
objects.
- Returns:
- an array of listeners
public TreeSelectionListener[] getTreeSelectionListeners()
Returns all addedTreeSelectionListener
objects.
- Returns:
- an array of listeners
public TreeWillExpandListener[] getTreeWillExpandListeners()
Returns all addedTreeWillExpandListener
objects.
- Returns:
- an array of listeners
public TreeUI getUI()
Return the UI associated with thisJTree
object.
- Returns:
- the associated
TreeUI
object
public String getUIClassID()
This method returns the String ID of the UI class of Separator.
- Overrides:
- getUIClassID in interface JComponent
- Returns:
- The UI class' String ID.
public boolean isEditable()
Checks if thisJTree
object is editable.
- Returns:
true
if this tree object is editable,false
otherwise
public boolean isRootVisible()
Checks if the root element is visible.
- Returns:
true
if the root element is visible,false
otherwise
public boolean isRowSelected(int row)
Returnstrue
when the specified row is selected,false
otherwise. This call is delegated to theTreeSelectionModel.isRowSelected(int)
method.
- Parameters:
row
- the row to check
- Returns:
true
when the specified row is selected,false
otherwise
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 benull
.
- Overrides:
- paramString in interface JComponent
- Returns:
- a String representation of this JTree
protected boolean removeDescendantSelectedPaths(TreePath path, boolean includeSelected)
Removes any paths in the current set of selected paths that are descendants ofpath
. IfincludePath
is set totrue
andpath
itself is selected, then it will be removed too.
- Parameters:
path
- the path from which selected descendants are to be removedincludeSelected
- iftrue
thenpath
itself will also be remove if it's selected
- Returns:
true
if something has been removed,false
otherwise
- Since:
- 1.3
protected void removeDescendantToggledPaths(EnumerationtoRemove)
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.
public void removeTreeExpansionListener(TreeExpansionListener listener)
Removes aTreeExpansionListener
object from the tree.
- Parameters:
listener
- the listener to remove
public void removeTreeSelectionListener(TreeSelectionListener listener)
Removes aTreeSelectionListener
object from the tree.
- Parameters:
listener
- the listener to remove
public void removeTreeWillExpandListener(TreeWillExpandListener listener)
Removes aTreeWillExpandListener
object from the tree.
- Parameters:
listener
- the listener to remove
public void setDragEnabled(boolean enabled)
Set thedragEnabled
property.
- Parameters:
enabled
- new value
- Since:
- 1.4
public void setEditable(boolean flag)
Sets theeditable
property.
- Parameters:
flag
-true
to make this tree object editable,false
otherwise
public void setModel(TreeModel model)
Sets the model to use inJTree
.
- Parameters:
model
- theTreeModel
to use
public void setUI(TreeUI ui)
Sets the UI associated with thisJTree
object.
- Parameters:
ui
- theTreeUI
to associate
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 callDefaultTreeModel.reload(TreeNode)
orDefaultTreeModel.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:
DefaultTreeModel.reload()
public void updateUI()
This method resets the UI used to the Look and Feel defaults..
- Overrides:
- updateUI in interface JComponent