public class JTree extends JComponent implements Scrollable, Accessible
| Modifier and Type | Class and Description |
|---|---|
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.
|
JComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategyaccessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
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. |
| Modifier and Type | Method and Description |
|---|---|
void |
addSelectionInterval(int index0,
int index1)
Select all rows between the two given indexes, inclusive.
|
void |
addSelectionPath(TreePath path) |
void |
addSelectionPaths(TreePath[] paths) |
void |
addSelectionRow(int row) |
void |
addSelectionRows(int[] rows) |
void |
addTreeExpansionListener(TreeExpansionListener listener)
Adds a
TreeExpansionListener object to the tree. |
void |
addTreeSelectionListener(TreeSelectionListener listener)
Adds a
TreeSelctionListener object to the tree. |
void |
addTreeWillExpandListener(TreeWillExpandListener listener)
Adds a
TreeWillExpandListener object to the tree. |
void |
cancelEditing() |
void |
clearSelection() |
protected void |
clearToggledPaths() |
void |
collapsePath(TreePath path) |
void |
collapseRow(int row) |
String |
convertValueToText(Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus)
Converts the specified value to a String.
|
protected static TreeModel |
createTreeModel(Object value)
Creates a new
TreeModel object. |
protected TreeModelListener |
createTreeModelListener()
Creates and returns an instance of
JTree.TreeModelHandler. |
void |
expandPath(TreePath path) |
void |
expandRow(int row) |
void |
fireTreeCollapsed(TreePath path)
Notifies all listeners that the tree was collapsed.
|
void |
fireTreeExpanded(TreePath path)
Notifies all listeners that the tree was expanded.
|
void |
fireTreeWillCollapse(TreePath path)
Notifies all listeners that the tree will collapse.
|
void |
fireTreeWillExpand(TreePath path)
Notifies all listeners that the tree will expand.
|
protected void |
fireValueChanged(TreeSelectionEvent event)
Notifies all listeners when the selection of the tree changed.
|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this
JTree. |
TreePath |
getAnchorSelectionPath() |
TreeCellEditor |
getCellEditor() |
TreeCellRenderer |
getCellRenderer() |
TreePath |
getClosestPathForLocation(int x,
int y) |
int |
getClosestRowForLocation(int x,
int y) |
protected static TreeModel |
getDefaultTreeModel()
Returns a sample TreeModel that can be used in a JTree.
|
protected Enumeration<TreePath> |
getDescendantToggledPaths(TreePath parent) |
boolean |
getDragEnabled()
Return the value of the
dragEnabled property. |
TreePath |
getEditingPath() |
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.
|
boolean |
getExpandsSelectedPaths() |
boolean |
getInvokesStopCellEditing() |
Object |
getLastSelectedPathComponent() |
TreePath |
getLeadSelectionPath() |
int |
getLeadSelectionRow() |
int |
getMaxSelectionRow() |
int |
getMinSelectionRow() |
TreeModel |
getModel()
Returns the model of this
JTree object. |
TreePath |
getNextMatch(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.
|
Rectangle |
getPathBounds(TreePath path) |
TreePath |
getPathForLocation(int x,
int y) |
TreePath |
getPathForRow(int row) |
Dimension |
getPreferredScrollableViewportSize()
Returns the preferred viewport size.
|
Rectangle |
getRowBounds(int row) |
int |
getRowCount() |
int |
getRowForLocation(int x,
int y) |
int |
getRowForPath(TreePath path) |
int |
getRowHeight() |
int |
getScrollableBlockIncrement(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(Rectangle visibleRect,
int orientation,
int direction)
Return the preferred scrolling amount (in pixels) for the given scrolling
direction and orientation.
|
boolean |
getScrollsOnExpand() |
int |
getSelectionCount() |
TreeSelectionModel |
getSelectionModel() |
TreePath |
getSelectionPath() |
TreePath[] |
getSelectionPaths() |
int[] |
getSelectionRows() |
boolean |
getShowsRootHandles() |
int |
getToggleClickCount() |
TreeExpansionListener[] |
getTreeExpansionListeners()
Returns all added
TreeExpansionListener objects. |
TreeSelectionListener[] |
getTreeSelectionListeners()
Returns all added
TreeSelectionListener objects. |
TreeWillExpandListener[] |
getTreeWillExpandListeners()
Returns all added
TreeWillExpandListener objects. |
TreeUI |
getUI()
Return the UI associated with this
JTree object. |
String |
getUIClassID()
This method returns the String ID of the UI class of Separator.
|
int |
getVisibleRowCount() |
boolean |
hasBeenExpanded(TreePath path) |
boolean |
isCollapsed(int row) |
boolean |
isCollapsed(TreePath path) |
boolean |
isEditable()
Checks if this
JTree object is editable. |
boolean |
isEditing() |
boolean |
isExpanded(int row) |
boolean |
isExpanded(TreePath path) |
boolean |
isFixedRowHeight() |
boolean |
isLargeModel() |
boolean |
isPathEditable(TreePath path) |
boolean |
isPathSelected(TreePath path) |
boolean |
isRootVisible()
Checks if the root element is visible.
|
boolean |
isRowSelected(int row)
Returns
true when the specified row is selected,
false otherwise. |
boolean |
isSelectionEmpty() |
boolean |
isVisible(TreePath path) |
void |
makeVisible(TreePath path) |
protected String |
paramString()
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 of
path. |
protected void |
removeDescendantToggledPaths(Enumeration<TreePath> toRemove)
Removes any descendants of the TreePaths in toRemove that have been
expanded.
|
void |
removeSelectionInterval(int index0,
int index1) |
void |
removeSelectionPath(TreePath path) |
void |
removeSelectionPaths(TreePath[] paths) |
void |
removeSelectionRow(int row) |
void |
removeSelectionRows(int[] rows) |
void |
removeTreeExpansionListener(TreeExpansionListener listener)
Removes a
TreeExpansionListener object from the tree. |
void |
removeTreeSelectionListener(TreeSelectionListener listener)
Removes a
TreeSelectionListener object from the tree. |
void |
removeTreeWillExpandListener(TreeWillExpandListener listener)
Removes a
TreeWillExpandListener object from the tree. |
void |
scrollPathToVisible(TreePath path) |
void |
scrollRowToVisible(int row) |
void |
setAnchorSelectionPath(TreePath path) |
void |
setCellEditor(TreeCellEditor editor) |
void |
setCellRenderer(TreeCellRenderer newRenderer) |
void |
setDragEnabled(boolean enabled)
Set the
dragEnabled property. |
void |
setEditable(boolean flag)
Sets the
editable property. |
protected void |
setExpandedState(TreePath path,
boolean state) |
void |
setExpandsSelectedPaths(boolean flag) |
void |
setInvokesStopCellEditing(boolean invoke) |
void |
setLargeModel(boolean large) |
void |
setLeadSelectionPath(TreePath path) |
void |
setModel(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(TreeSelectionModel model) |
void |
setSelectionPath(TreePath path) |
void |
setSelectionPaths(TreePath[] paths) |
void |
setSelectionRow(int row) |
void |
setSelectionRows(int[] rows) |
void |
setShowsRootHandles(boolean flag) |
void |
setToggleClickCount(int count) |
void |
setUI(TreeUI ui)
Sets the UI associated with this
JTree object. |
void |
setVisibleRowCount(int rows) |
void |
startEditingAtPath(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..
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final String CELL_EDITOR_PROPERTY
public static final String CELL_RENDERER_PROPERTY
public static final String EDITABLE_PROPERTY
public static final String INVOKES_STOP_CELL_EDITING_PROPERTY
public static final String LARGE_MODEL_PROPERTY
public static final String ROOT_VISIBLE_PROPERTY
public static final String ROW_HEIGHT_PROPERTY
public static final String SCROLLS_ON_EXPAND_PROPERTY
public static final String SELECTION_MODEL_PROPERTY
public static final String SHOWS_ROOT_HANDLES_PROPERTY
public static final String TOGGLE_CLICK_COUNT_PROPERTY
public static final String TREE_MODEL_PROPERTY
public static final String VISIBLE_ROW_COUNT_PROPERTY
public static final String ANCHOR_SELECTION_PATH_PROPERTY
public static final String LEAD_SELECTION_PATH_PROPERTY
public static final String EXPANDS_SELECTED_PATHS_PROPERTY
protected transient TreeCellEditor cellEditor
protected transient TreeCellRenderer cellRenderer
protected boolean editable
protected boolean invokesStopCellEditing
protected boolean largeModel
protected boolean rootVisible
protected int rowHeight
protected boolean scrollsOnExpand
protected transient TreeSelectionModel selectionModel
protected boolean showsRootHandles
protected int toggleClickCount
protected int visibleRowCount
protected transient TreeModelListener treeModelListener
protected JTree.TreeSelectionRedirector selectionRedirector
public JTree()
JTree object.public JTree(Hashtable<?,?> value)
JTree object.value - the initial nodes in the treepublic JTree(Object[] value)
JTree object.value - the initial nodes in the treepublic JTree(TreeNode root, boolean asksAllowChildren)
JTree object.root - the root nodeasksAllowChildren - if false, all nodes without children are leaf
nodes. If true, only nodes that do not allow children are leaf
nodes.public int getRowForPath(TreePath path)
public TreePath getPathForRow(int row)
protected TreePath[] getPathBetweenRows(int index0, int index1)
index0 - the starting row, inclusiveindex1 - the ending row, inclusiveprotected static TreeModel createTreeModel(Object value)
TreeModel object.value - the values stored in the modelpublic TreeUI getUI()
JTree object.TreeUI objectpublic void setUI(TreeUI ui)
JTree object.ui - the TreeUI to associatepublic void updateUI()
updateUI in class JComponentpublic String getUIClassID()
getUIClassID in class JComponentJComponent.setUI(javax.swing.plaf.ComponentUI),
JComponent.updateUI()public AccessibleContext getAccessibleContext()
JTree.getAccessibleContext in interface AccessiblegetAccessibleContext in class JComponentpublic Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize in interface Scrollablepublic int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement in interface ScrollablevisibleRect - 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 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
ScrollablegetScrollableBlockIncrement in interface ScrollablevisibleRect - 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 boolean getScrollableTracksViewportHeight()
ScrollablegetScrollableTracksViewportHeight in interface Scrollablepublic boolean getScrollableTracksViewportWidth()
ScrollablegetScrollableTracksViewportWidth in interface Scrollablepublic void addTreeExpansionListener(TreeExpansionListener listener)
TreeExpansionListener object to the tree.listener - the listener to addpublic void removeTreeExpansionListener(TreeExpansionListener listener)
TreeExpansionListener object from the tree.listener - the listener to removepublic TreeExpansionListener[] getTreeExpansionListeners()
TreeExpansionListener objects.public void fireTreeCollapsed(TreePath path)
path - the path to the node that was collapsedpublic void fireTreeExpanded(TreePath path)
path - the path to the node that was expandedpublic void addTreeSelectionListener(TreeSelectionListener listener)
TreeSelctionListener object to the tree.listener - the listener to addpublic void removeTreeSelectionListener(TreeSelectionListener listener)
TreeSelectionListener object from the tree.listener - the listener to removepublic TreeSelectionListener[] getTreeSelectionListeners()
TreeSelectionListener objects.protected void fireValueChanged(TreeSelectionEvent event)
event - the event to sendpublic void addTreeWillExpandListener(TreeWillExpandListener listener)
TreeWillExpandListener object to the tree.listener - the listener to addpublic void removeTreeWillExpandListener(TreeWillExpandListener listener)
TreeWillExpandListener object from the tree.listener - the listener to removepublic TreeWillExpandListener[] getTreeWillExpandListeners()
TreeWillExpandListener objects.public void fireTreeWillCollapse(TreePath path) throws ExpandVetoException
path - the path to the node that will collapseExpandVetoExceptionpublic void fireTreeWillExpand(TreePath path) throws ExpandVetoException
path - the path to the node that will expandExpandVetoExceptionpublic TreeModel getModel()
JTree object.TreeModelpublic void setModel(TreeModel model)
JTree.model - the TreeModel to usepublic boolean isEditable()
JTree object is editable.true if this tree object is editable,
false otherwisepublic void setEditable(boolean flag)
editable property.flag - true to make this tree object editable,
false otherwisepublic boolean isRootVisible()
true if the root element is visible,
false otherwisepublic void setRootVisible(boolean flag)
public boolean getShowsRootHandles()
public void setShowsRootHandles(boolean flag)
public TreeCellEditor getCellEditor()
public void setCellEditor(TreeCellEditor editor)
public TreeCellRenderer getCellRenderer()
public void setCellRenderer(TreeCellRenderer newRenderer)
public TreeSelectionModel getSelectionModel()
public void setSelectionModel(TreeSelectionModel model)
public int getVisibleRowCount()
public void setVisibleRowCount(int rows)
public boolean isLargeModel()
public void setLargeModel(boolean large)
public int getRowHeight()
public void setRowHeight(int height)
public boolean isFixedRowHeight()
public boolean getInvokesStopCellEditing()
public void setInvokesStopCellEditing(boolean invoke)
public int getToggleClickCount()
public void setToggleClickCount(int count)
public void scrollPathToVisible(TreePath path)
public void scrollRowToVisible(int row)
public boolean getScrollsOnExpand()
public void setScrollsOnExpand(boolean scroll)
public void setSelectionPath(TreePath path)
public void setSelectionPaths(TreePath[] paths)
public void setSelectionRow(int row)
public void setSelectionRows(int[] rows)
public void setSelectionInterval(int index0, int index1)
public void addSelectionPath(TreePath path)
public void addSelectionPaths(TreePath[] paths)
public void addSelectionRow(int row)
public void addSelectionRows(int[] rows)
public void addSelectionInterval(int index0, int index1)
index0 - the starting row, inclusiveindex1 - the ending row, inclusivepublic void removeSelectionPath(TreePath path)
public void removeSelectionPaths(TreePath[] paths)
public void removeSelectionRow(int row)
public void removeSelectionRows(int[] rows)
public void removeSelectionInterval(int index0, int index1)
public void clearSelection()
public TreePath getLeadSelectionPath()
public void setLeadSelectionPath(TreePath path)
public TreePath getAnchorSelectionPath()
public void setAnchorSelectionPath(TreePath path)
public int getLeadSelectionRow()
public int getMaxSelectionRow()
public int getMinSelectionRow()
public int getSelectionCount()
public TreePath getSelectionPath()
public TreePath[] getSelectionPaths()
public int[] getSelectionRows()
public boolean isPathSelected(TreePath path)
public boolean isRowSelected(int row)
true when the specified row is selected,
false otherwise. This call is delegated to the
TreeSelectionModel.isRowSelected(int) method.row - the row to checktrue when the specified row is selected,
false otherwisepublic boolean isSelectionEmpty()
public boolean getDragEnabled()
dragEnabled property.public void setDragEnabled(boolean enabled)
dragEnabled property.enabled - new valuepublic int getRowCount()
public void collapsePath(TreePath path)
public void collapseRow(int row)
public void expandPath(TreePath path)
public void expandRow(int row)
public boolean isCollapsed(TreePath path)
public boolean isCollapsed(int row)
public boolean isExpanded(TreePath path)
public boolean isExpanded(int row)
public boolean getExpandsSelectedPaths()
public void setExpandsSelectedPaths(boolean flag)
public Rectangle getPathBounds(TreePath path)
public Rectangle getRowBounds(int row)
public boolean isEditing()
public boolean stopEditing()
public void cancelEditing()
public void startEditingAtPath(TreePath path)
public TreePath getEditingPath()
public TreePath getPathForLocation(int x, int y)
public int getRowForLocation(int x, int y)
public TreePath getClosestPathForLocation(int x, int y)
public int getClosestRowForLocation(int x, int y)
public Object getLastSelectedPathComponent()
protected void setExpandedState(TreePath path, boolean state)
protected void clearToggledPaths()
protected Enumeration<TreePath> getDescendantToggledPaths(TreePath parent)
public boolean hasBeenExpanded(TreePath path)
public void makeVisible(TreePath path)
public boolean isPathEditable(TreePath path)
protected TreeModelListener createTreeModelListener()
JTree.TreeModelHandler.JTree.TreeModelHandlerprotected static TreeModel getDefaultTreeModel()
public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
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 notprotected String paramString()
null.paramString in class JComponentpublic Enumeration<TreePath> getExpandedDescendants(TreePath path)
path - The parent of this requestpublic TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias)
startingRow that starts with prefix.
Searching is done in the direction specified by bias.prefix - the prefix to search for in the cell valuesstartingRow - the index of the row where to start searching frombias - the search direction, either Position.Bias#Forward or
Position.Bias#BackwardIllegalArgumentException - if prefix is null or
startingRow is not validprotected boolean removeDescendantSelectedPaths(TreePath path, boolean includeSelected)
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 selectedtrue if something has been removed,
false otherwiseprotected void removeDescendantToggledPaths(Enumeration<TreePath> toRemove)
toRemove - - Enumeration of TreePaths that need to be removed from
cache of toggled tree paths.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.
DefaultTreeModel.reload()