|
|||||||||
| Home >> All >> javax >> [ swing overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
javax.swing
Class JTree

java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTree
- All Implemented Interfaces:
- javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, Scrollable, java.io.Serializable
- public class JTree
- extends JComponent
- implements Scrollable, javax.accessibility.Accessible
- extends JComponent
| Nested Class Summary | |
protected class |
JTree.AccessibleJTree
This class implements accessibility support for the JTree class. |
static class |
JTree.DynamicUtilTreeNode
|
protected static class |
JTree.EmptySelectionModel
A TreeModel that does not allow anything to be selected. |
protected class |
JTree.TreeModelHandler
Listens to the model of the JTree and updates the property expandedState if nodes are removed or changed. |
protected class |
JTree.TreeSelectionRedirector
This redirects TreeSelectionEvents and rewrites the source of it to be this JTree. |
| Nested classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Fields inherited from class javax.swing.JComponent |
accessibleContext, alignmentX, alignmentY, autoscrolls, border, debugGraphicsOptions, doubleBuffered, isCompletelyDirty, isPaintingDoubleBuffered, listenerList, maximumSize, minimumSize, opaque, preferredSize, requestFocusEnabled, TOOL_TIP_TEXT_KEY, toolTipText, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
|
| 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 | |
JTree()
Creates a new JTree object. |
|
JTree(java.util.Hashtable value)
Creates a new JTree object. |
|
JTree(java.lang.Object[] value)
Creates a new JTree object. |
|
JTree(javax.swing.tree.TreeModel model)
Creates a new JTree object. |
|
JTree(javax.swing.tree.TreeNode root)
Creates a new JTree object. |
|
JTree(javax.swing.tree.TreeNode root,
boolean asksAllowChildren)
Creates a new JTree object. |
|
JTree(java.util.Vector value)
Creates a new JTree object. |
|
| Method Summary | |
void |
addSelectionInterval(int index0,
int index1)
Select all rows between the two given indexes, inclusive. |
void |
addSelectionPath(javax.swing.tree.TreePath path)
|
void |
addSelectionPaths(javax.swing.tree.TreePath[] paths)
|
void |
addSelectionRow(int row)
|
void |
addSelectionRows(int[] rows)
|
void |
addTreeExpansionListener(javax.swing.event.TreeExpansionListener listener)
Adds a TreeExpansionListener object to the tree. |
void |
addTreeSelectionListener(javax.swing.event.TreeSelectionListener listener)
Adds a TreeSelctionListener object to the tree. |
void |
addTreeWillExpandListener(javax.swing.event.TreeWillExpandListener listener)
Adds a TreeWillExpandListener object to the tree. |
void |
cancelEditing()
|
void |
clearSelection()
|
protected void |
clearToggledPaths()
|
void |
collapsePath(javax.swing.tree.TreePath path)
|
void |
collapseRow(int row)
|
java.lang.String |
convertValueToText(java.lang.Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus)
Converts the specified value to a String. |
protected static javax.swing.tree.TreeModel |
createTreeModel(java.lang.Object value)
Creates a new TreeModel object. |
protected javax.swing.event.TreeModelListener |
createTreeModelListener()
Creates and returns an instance of JTree.TreeModelHandler. |
private void |
doExpandParents(javax.swing.tree.TreePath path,
boolean state)
|
void |
expandPath(javax.swing.tree.TreePath path)
|
void |
expandRow(int row)
|
void |
fireTreeCollapsed(javax.swing.tree.TreePath path)
Notifies all listeners that the tree was collapsed. |
void |
fireTreeExpanded(javax.swing.tree.TreePath path)
Notifies all listeners that the tree was expanded. |
void |
fireTreeWillCollapse(javax.swing.tree.TreePath path)
Notifies all listeners that the tree will collapse. |
void |
fireTreeWillExpand(javax.swing.tree.TreePath path)
Notifies all listeners that the tree will expand. |
protected void |
fireValueChanged(javax.swing.event.TreeSelectionEvent event)
Notifies all listeners when the selection of the tree changed. |
javax.accessibility.AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this JTree. |
javax.swing.tree.TreePath |
getAnchorSelectionPath()
|
javax.swing.tree.TreeCellEditor |
getCellEditor()
|
javax.swing.tree.TreeCellRenderer |
getCellRenderer()
|
javax.swing.tree.TreePath |
getClosestPathForLocation(int x,
int y)
|
int |
getClosestRowForLocation(int x,
int y)
|
protected static javax.swing.tree.TreeModel |
getDefaultTreeModel()
Returns a sample TreeModel that can be used in a JTree. |
protected java.util.Enumeration |
getDescendantToggledPaths(javax.swing.tree.TreePath parent)
|
boolean |
getDragEnabled()
Return the value of the dragEnabled property. |
javax.swing.tree.TreePath |
getEditingPath()
|
java.util.Enumeration |
getExpandedDescendants(javax.swing.tree.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. |
boolean |
getExpandsSelectedPaths()
|
boolean |
getInvokesStopCellEditing()
|
java.lang.Object |
getLastSelectedPathComponent()
|
javax.swing.tree.TreePath |
getLeadSelectionPath()
|
int |
getLeadSelectionRow()
|
int |
getMaxSelectionRow()
|
int |
getMinSelectionRow()
|
javax.swing.tree.TreeModel |
getModel()
Returns the model of this JTree object. |
javax.swing.tree.TreePath |
getNextMatch(java.lang.String prefix,
int startingRow,
javax.swing.text.Position.Bias bias)
Returns the next table element (beginning from the row startingRow that starts with prefix. |
protected javax.swing.tree.TreePath[] |
getPathBetweenRows(int index0,
int index1)
Get the pathes that are displayes between the two given rows. |
java.awt.Rectangle |
getPathBounds(javax.swing.tree.TreePath path)
|
javax.swing.tree.TreePath |
getPathForLocation(int x,
int y)
|
javax.swing.tree.TreePath |
getPathForRow(int row)
|
java.awt.Dimension |
getPreferredScrollableViewportSize()
Returns the preferred viewport size. |
java.awt.Rectangle |
getRowBounds(int row)
|
int |
getRowCount()
|
int |
getRowForLocation(int x,
int y)
|
int |
getRowForPath(javax.swing.tree.TreePath path)
|
int |
getRowHeight()
|
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Return the preferred scrolling amount (in pixels) for the given scrolling direction and orientation when scrolling in large amounts (pages). |
boolean |
getScrollableTracksViewportHeight()
Return true if the height of the scrollable is always equal to the view, where it is displayed, height.In such case, the vertical scrolling should not be performed. |
boolean |
getScrollableTracksViewportWidth()
Return true if the width of the scrollable is always equal to the view, where it is displayed, width (for instance, the text area with the word wrap). |
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Return the preferred scrolling amount (in pixels) for the given scrolling direction and orientation. |
boolean |
getScrollsOnExpand()
|
int |
getSelectionCount()
|
javax.swing.tree.TreeSelectionModel |
getSelectionModel()
|
javax.swing.tree.TreePath |
getSelectionPath()
|
javax.swing.tree.TreePath[] |
getSelectionPaths()
|
int[] |
getSelectionRows()
|
boolean |
getShowsRootHandles()
|
int |
getToggleClickCount()
|
javax.swing.event.TreeExpansionListener[] |
getTreeExpansionListeners()
Returns all added TreeExpansionListener objects. |
javax.swing.event.TreeSelectionListener[] |
getTreeSelectionListeners()
Returns all added TreeSelectionListener objects. |
javax.swing.event.TreeWillExpandListener[] |
getTreeWillExpandListeners()
Returns all added TreeWillExpandListener objects. |
javax.swing.plaf.TreeUI |
getUI()
Return the UI associated with this JTree object. |
java.lang.String |
getUIClassID()
This method returns the String ID of the UI class of Separator. |
int |
getVisibleRowCount()
|
boolean |
hasBeenExpanded(javax.swing.tree.TreePath path)
|
boolean |
isCollapsed(int row)
|
boolean |
isCollapsed(javax.swing.tree.TreePath path)
|
boolean |
isEditable()
Checks if this JTree object is editable. |
boolean |
isEditing()
|
boolean |
isExpanded(int row)
|
boolean |
isExpanded(javax.swing.tree.TreePath path)
|
boolean |
isFixedRowHeight()
|
boolean |
isLargeModel()
|
boolean |
isPathEditable(javax.swing.tree.TreePath path)
|
boolean |
isPathSelected(javax.swing.tree.TreePath path)
|
boolean |
isRootVisible()
Checks if the root element is visible. |
boolean |
isRowSelected(int row)
|
boolean |
isSelectionEmpty()
|
boolean |
isVisible(javax.swing.tree.TreePath path)
|
void |
makeVisible(javax.swing.tree.TreePath path)
|
protected java.lang.String |
paramString()
A String representation of this JTree. |
protected boolean |
removeDescendantSelectedPaths(javax.swing.tree.TreePath path,
boolean includeSelected)
Removes any paths in the current set of selected paths that are descendants of path. |
protected void |
removeDescendantToggledPaths(java.util.Enumeration toRemove)
Removes any descendants of the TreePaths in toRemove that have been expanded. |
void |
removeSelectionInterval(int index0,
int index1)
|
void |
removeSelectionPath(javax.swing.tree.TreePath path)
|
void |
removeSelectionPaths(javax.swing.tree.TreePath[] paths)
|
void |
removeSelectionRow(int row)
|
void |
removeSelectionRows(int[] rows)
|
void |
removeTreeExpansionListener(javax.swing.event.TreeExpansionListener listener)
Removes a TreeExpansionListener object from the tree. |
void |
removeTreeSelectionListener(javax.swing.event.TreeSelectionListener listener)
Removes a TreeSelectionListener object from the tree. |
void |
removeTreeWillExpandListener(javax.swing.event.TreeWillExpandListener listener)
Removes a TreeWillExpandListener object from the tree. |
void |
scrollPathToVisible(javax.swing.tree.TreePath path)
|
void |
scrollRowToVisible(int row)
|
void |
setAnchorSelectionPath(javax.swing.tree.TreePath path)
|
void |
setCellEditor(javax.swing.tree.TreeCellEditor editor)
|
void |
setCellRenderer(javax.swing.tree.TreeCellRenderer newRenderer)
|
void |
setDragEnabled(boolean enabled)
Set the dragEnabled property. |
void |
setEditable(boolean flag)
Sets the editable property. |
protected void |
setExpandedState(javax.swing.tree.TreePath path,
boolean state)
|
void |
setExpandsSelectedPaths(boolean flag)
|
void |
setInvokesStopCellEditing(boolean invoke)
|
void |
setLargeModel(boolean large)
|
void |
setLeadSelectionPath(javax.swing.tree.TreePath path)
|
void |
setModel(javax.swing.tree.TreeModel model)
Sets the model to use in JTree. |
void |
setRootVisible(boolean flag)
|
void |
setRowHeight(int height)
|
void |
setScrollsOnExpand(boolean scroll)
|
void |
setSelectionInterval(int index0,
int index1)
|
void |
setSelectionModel(javax.swing.tree.TreeSelectionModel model)
|
void |
setSelectionPath(javax.swing.tree.TreePath path)
|
void |
setSelectionPaths(javax.swing.tree.TreePath[] paths)
|
void |
setSelectionRow(int row)
|
void |
setSelectionRows(int[] rows)
|
void |
setShowsRootHandles(boolean flag)
|
void |
setToggleClickCount(int count)
|
void |
setUI(javax.swing.plaf.TreeUI ui)
Sets the UI associated with this JTree object. |
(package private) void |
setUIProperty(java.lang.String propertyName,
java.lang.Object value)
Helper method for LookAndFeel.installProperty(JComponent, String, Object) 55 . |
void |
setVisibleRowCount(int rows)
|
void |
startEditingAtPath(javax.swing.tree.TreePath path)
|
boolean |
stopEditing()
|
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). |
void |
updateUI()
This method resets the UI used to the Look and Feel defaults.. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
CELL_EDITOR_PROPERTY
public static final java.lang.String CELL_EDITOR_PROPERTY
- See Also:
- Constant Field Values
CELL_RENDERER_PROPERTY
public static final java.lang.String CELL_RENDERER_PROPERTY
- See Also:
- Constant Field Values
EDITABLE_PROPERTY
public static final java.lang.String EDITABLE_PROPERTY
- See Also:
- Constant Field Values
INVOKES_STOP_CELL_EDITING_PROPERTY
public static final java.lang.String INVOKES_STOP_CELL_EDITING_PROPERTY
- See Also:
- Constant Field Values
LARGE_MODEL_PROPERTY
public static final java.lang.String LARGE_MODEL_PROPERTY
- See Also:
- Constant Field Values
ROOT_VISIBLE_PROPERTY
public static final java.lang.String ROOT_VISIBLE_PROPERTY
- See Also:
- Constant Field Values
ROW_HEIGHT_PROPERTY
public static final java.lang.String ROW_HEIGHT_PROPERTY
- See Also:
- Constant Field Values
SCROLLS_ON_EXPAND_PROPERTY
public static final java.lang.String SCROLLS_ON_EXPAND_PROPERTY
- See Also:
- Constant Field Values
SELECTION_MODEL_PROPERTY
public static final java.lang.String SELECTION_MODEL_PROPERTY
- See Also:
- Constant Field Values
SHOWS_ROOT_HANDLES_PROPERTY
public static final java.lang.String SHOWS_ROOT_HANDLES_PROPERTY
- See Also:
- Constant Field Values
TOGGLE_CLICK_COUNT_PROPERTY
public static final java.lang.String TOGGLE_CLICK_COUNT_PROPERTY
- See Also:
- Constant Field Values
TREE_MODEL_PROPERTY
public static final java.lang.String TREE_MODEL_PROPERTY
- See Also:
- Constant Field Values
VISIBLE_ROW_COUNT_PROPERTY
public static final java.lang.String VISIBLE_ROW_COUNT_PROPERTY
- See Also:
- Constant Field Values
ANCHOR_SELECTION_PATH_PROPERTY
public static final java.lang.String ANCHOR_SELECTION_PATH_PROPERTY
- Since:
- 1.3
- See Also:
- Constant Field Values
LEAD_SELECTION_PATH_PROPERTY
public static final java.lang.String LEAD_SELECTION_PATH_PROPERTY
- Since:
- 1.3
- See Also:
- Constant Field Values
EXPANDS_SELECTED_PATHS_PROPERTY
public static final java.lang.String EXPANDS_SELECTED_PATHS_PROPERTY
- Since:
- 1.3
- See Also:
- Constant Field Values
EXPANDED
private static final java.lang.Object EXPANDED
COLLAPSED
private static final java.lang.Object COLLAPSED
dragEnabled
private boolean dragEnabled
expandsSelectedPaths
private boolean expandsSelectedPaths
anchorSelectionPath
private javax.swing.tree.TreePath anchorSelectionPath
nodeStates
private java.util.Hashtable nodeStates
- This contains the state of all nodes in the tree. Al/ entries map the
TreePath of a note to to its state. Valid states are EXPANDED and
COLLAPSED. Nodes not in this Hashtable are assumed state COLLAPSED.
cellEditor
protected transient javax.swing.tree.TreeCellEditor cellEditor
cellRenderer
protected transient javax.swing.tree.TreeCellRenderer cellRenderer
editable
protected boolean editable
invokesStopCellEditing
protected boolean invokesStopCellEditing
largeModel
protected boolean largeModel
rootVisible
protected boolean rootVisible
rowHeight
protected int rowHeight
scrollsOnExpand
protected boolean scrollsOnExpand
selectionModel
protected transient javax.swing.tree.TreeSelectionModel selectionModel
showsRootHandles
protected boolean showsRootHandles
toggleClickCount
protected int toggleClickCount
treeModel
protected transient javax.swing.tree.TreeModel treeModel
visibleRowCount
protected int visibleRowCount
treeModelListener
protected transient
JAVADOC