All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.JTree

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.JTree

public class JTree
extends JComponent
implements Scrollable
A control that displays a set of hierarchical data as an outline.

If you are interested in knowing when the selection changes implement the TreeSelectionListener interface and add the instance using the method addTreeSelectionListener. valueChanged will be invoked when the selection changes, that is if the user clicks twice on the same node valueChanged will only be invoked once.

If you are interested in knowing either double clicks events or when a user clicks on a node, regardless of whether or not it was selected it is recommended you do the following:

 final JTree tree = ...;
 MouseListener ml = new MouseAdapter() {
     public void mouseClicked(MouseEvent e) {
         int selRow = tree.getRowForLocation(e.getX(), e.getY());
         int selPath = tree.getPathForLocation(e.getX(), e.getY());
	   if(selRow != -1) {
             if(e.getClickCount() == 1) {
	           mySingleClick(selRow, selPath);
             }
	       else if(e.getClickCount() == 2) {
	           myDoubleClick(selRow, selPath);
	       }
         }
     }
 };
 tree.addMouseListener(ml);
NOTE: I obtained both the path and row for illustrative purposes, you only need to get the one you're interested in.


Variable Index

 o CELL_EDITOR_PROPERTY
Bound property name for cellEditor.
 o CELL_RENDERER_PROPERTY
Bound property name for cellRenderer.
 o cellEditor
Editor for the entries.
 o cellRenderer
The cell used to draw nodes.
 o editable
Is the tree editable?
 o EDITABLE_PROPERTY
Bound property name for editable.
 o LARGE_MODEL_PROPERTY
Bound property name for largeModel.
 o largeModel
Is the receiver a large model? This is only a suggestion to the UI, not all UIs will implement this.
 o ROOT_VISIBLE_PROPERTY
Bound property name for rootVisible.
 o rootVisible
True if the root node is displayed, false if its children are the highest visible nodes.
 o ROW_HEIGHT_PROPERTY
Bound property name for rowHeight.
 o rowHeight
Height to use for each row.
 o SELECTION_MODEL_PROPERTY
Bound property name for selectionModel.
 o selectionModel
Models the set of selected nodes in this tree.
 o selectionRedirector
Creates a new event and passed it off the selectionListeners.
 o SHOWS_ROOT_HANDLES_PROPERTY
Bound property name for showsRootHandles.
 o showsRootHandles
true if there should be handles at the top level.
 o TREE_MODEL_PROPERTY
Bound property name for treeModel.
 o treeModel
The model that defines the tree displayed by this object.
 o VISIBLE_ROW_COUNT_PROPERTY
Bound property name for visibleRowCount.
 o visibleRowCount
Number of rows to make visible at one time.

Constructor Index

 o JTree()
Returns a JTree with a sample model.
 o JTree(Hashtable)
Returns a JTree with each element of value as the child of a root node.
 o JTree(Object[])
Returns a JTree with each element of value as the child of a root node.
 o JTree(TreeModel)
Returns an instance of JTree using the TreeModel newModel.
 o JTree(TreeNode)
Returns a JTree with an instance of JTreeModel as its data model, rooted at root and asksAllowsChildren false.
 o JTree(TreeNode, boolean)
Returns a JTree with an instance of JTreeModel as its data model.
 o JTree(Vector)
Returns a JTree with each element of value as the child of a root node.

Method Index

 o addSelectionInterval(int, int)
Adds the paths between index0 and index1 to the selection.
 o addSelectionPath(TreePath)
Adds the path identified by path to the current selection.
 o addSelectionPaths(TreePath[])
Adds each path in paths to the current selection.
 o addSelectionRow(int)
Adds the paths at each of the rows in rows to the current selection.
 o addSelectionRows(int[])
Adds the paths at each of the rows in rows to the current selection.
 o addTreeExpansionListener(TreeExpansionListener)
Adds tel as interested in recieving TreeExpansion events.
 o addTreeSelectionListener(TreeSelectionListener)
Adds tsl as interested in recieving TreeSelection events.
 o clearSelection()
Clears the selection.
 o collapsePath(TreePath)
Insures that the last item identified in path is collapsed and visible.
 o collapseRow(int)
Insures that the item identified by row is collapsed.
 o convertValueToText(Object, boolean, boolean, boolean, int, boolean)
This is called by the renderers to convert the passed in value into text.
 o createTreeModel(Object)
Returns a TreeModel wrapping the passed in object value.
 o expandPath(TreePath)
Insures that the last item identified in path is expanded and visible.
 o expandRow(int)
Insures that the item identified by row is expanded.
 o fireTreeCollapsed(TreePath)
 o fireTreeExpanded(TreePath)
 o fireValueChanged(TreeSelectionEvent)
 o getCellEditor()
Returns the editor used to edit entries in the tree.
 o getCellRenderer()
Returns the current TreeCellRenderer that is rendering each cell.
 o getClosestPathForLocation(int, int)
Returns the path to the node that is closest to x,y.
 o getClosestRowForLocation(int, int)
Returns the row to the node that is closest to x,y.
 o getDefaultTreeModel()
Creates and returns a sample TreeModel.
 o getEditingPath()
Returns the path to the element that is being edited.
 o getLastSelectedPathComponent()
Returns the last path component in the selection.
 o getLeadSelectionPath()
Returns the last path that was added.
 o getLeadSelectionRow()
Returns the lead selection index.
 o getMaxSelectionRow()
Gets the last selected row.
 o getMinSelectionRow()
Gets the first selected row.
 o getModel()
Returns the TreeModel that is providing the data.
 o getPathBetweenRows(int, int)
Returns JTreePath instances representing the path between index0 and index1 (including index1).
 o getPathBounds(TreePath)
Returns the Rectangle that the last item in path will be drawn into.
 o getPathForLocation(int, int)
Returns the path for the given location.
 o getPathForRow(int)
Returns the path for passed in row.
 o getPreferredScrollableViewportSize()
Returns the preferred viewable size of a JTree.
 o getRowBounds(int)
Returns the Rectangle that the item identified by row will be drawn into.
 o getRowCount()
Returns the number of rows that are currently being displayed.
 o getRowForLocation(int, int)
Returns the row for the passed in location.
 o getRowForPath(TreePath)
Returns the row that the last item identified in path is visible at.
 o getRowHeight()
Returns the height of each row.
 o getScrollableBlockIncrement(Rectangle, int, int)
Returns the amount for a block inrecment, which is the height or width of visibleRect, based on orientation.
 o getScrollableTracksViewportHeight()
Returns false.
 o getScrollableTracksViewportWidth()
Returns false.
 o getScrollableUnitIncrement(Rectangle, int, int)
Returns the amount to increment when scrolling.
 o getSelectionCount()
Returns the number of nodes selected.
 o getSelectionModel()
Returns the model for selections.
 o getSelectionPath()
Returns the path to the first selected value, or null if nothing is currently selected.
 o getSelectionPaths()
Returns the path of the selected values, or null if nothing is current selected.
 o getSelectionRows()
Returns all of the currently selected rows.
 o getShowsRootHandles()
Returns true if handles for the root nodes are displayed.
 o getUI()
Returns the TreeUI that is providing the current look and feel.
 o getUIClassID()
 o getVisibleRowCount()
Returns the number of rows that are to be made visible.
 o isCollapsed(int)
Returns true if the value identified by row is currently collapsed.
 o isCollapsed(TreePath)
Returns true if the value identified by path is currently collapsed, this will return false if any of the values in path are currently not being displayed.
 o isEditable()
Returns true if the tree is editable.
 o isEditing()
Returns true if the tree is being edited.
 o isExpanded(int)
Returns true if the value identified by row is currently expanded.
 o isExpanded(TreePath)
Returns true if the value identified by path is currently expanded, this will return false if any of the values in path are currently not being displayed.
 o isFixedRowHeight()
Returns true if the height of each row is a fixed size.
 o isLargeModel()
Returns true if the receiver is configured for a large model.
 o isOpaque()
Returns true if this component is completely opaque.
 o isPathSelected(TreePath)
Returns true if item identified by path is currently selected.
 o isRootVisible()
Returns true if the root node from the TreeModel is currently visible.
 o isRowSelected(int)
Returns true if the row identitifed by row is selected.
 o isSelectionEmpty()
Returns true if the selection is currently empty.
 o isVisible(TreePath)
Returns true if the value identified by path is currently visible, false otherwise.
 o makeVisible(TreePath)
Insures that the value identified by path is currently visible.
 o removeSelectionInterval(int, int)
Removes the paths between index0 and index1 from the selection.
 o removeSelectionPath(TreePath)
Removes the path identified by path from the current selection.
 o removeSelectionPaths(TreePath[])
Removes the paths, identified by paths, from the current selection.
 o removeSelectionRow(int)
Removes the path at the index row from the current selection.
 o removeSelectionRows(int[])
Removes the paths that are selected at each of the indices in rows.
 o removeTreeExpansionListener(TreeExpansionListener)
Removes tel as being interested in recieving TreeExpansion events.
 o removeTreeSelectionListener(TreeSelectionListener)
Removes tsl as being interested in recieving TreeSelection events.
 o scrollPathToVisible(TreePath)
Makes sure all the path components in path are expanded (accept for the last path component) and tries to scroll the resulting path to be visible.
 o scrollRowToVisible(int)
Scrolls the item identified by row to be visible.
 o setCellEditor(TreeCellEditor)
Sets the cell editor to cellEditor.
 o setCellRenderer(TreeCellRenderer)
Sets the TreeCellRenderer that will be used to draw each cell.
 o setEditable(boolean)
Sets the tree to being editable based on flag.
 o setLargeModel(boolean)
Set the receiver to being a larged model based on newValue.
 o setModel(TreeModel)
Sets the TreeModel that will provide the data.
 o setRootVisible(boolean)
Sets, based on rootVisible, whether or not the root node from the TreeModel is visible.
 o setRowHeight(int)
Sets the height of each to be rowHeight.
 o setSelectionInterval(int, int)
Sets the selection to the paths of the nodes between index0 and index1.
 o setSelectionModel(TreeSelectionModel)
Sets the selection model to selectionModel.
 o setSelectionPath(TreePath)
Sets to selection to the value identified by path.
 o setSelectionPaths(TreePath[])
Sets the selection to paths.
 o setSelectionRow(int)
Sets the selection to the path at index row.
 o setSelectionRows(int[])
The selection is set to the paths for the items at each of the rows in rows.
 o setShowsRootHandles(boolean)
Sets whether or not the root handles are to be displayed.
 o setUI(TreeUI)
Sets the TreeUI that will provide the current look and feel.
 o setVisibleRowCount(int)
Sets the number of rows that are to be visible.
 o startEditingAtPath(TreePath)
Selects the last item in path and tries to edit it.
 o stopEditing()
Stops the current editing session.
 o 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)
 o updateUI()
Called to replace the UI with the latest version from the default UIFactory.

Variables

 o treeModel
 protected transient TreeModel treeModel
The model that defines the tree displayed by this object.

 o selectionModel
 protected transient TreeSelectionModel selectionModel
Models the set of selected nodes in this tree.

 o rootVisible
 protected boolean rootVisible
True if the root node is displayed, false if its children are the highest visible nodes.

 o cellRenderer
 protected transient TreeCellRenderer cellRenderer
The cell used to draw nodes. If null, the UI uses a default cellRenderer.

 o rowHeight
 protected int rowHeight
Height to use for each row. If this is <= 0 the renderer will be used to determine the height for each row.

 o showsRootHandles
 protected boolean showsRootHandles
true if there should be handles at the top level. If the root isn't visible it is highly recommended to make this true.

 o selectionRedirector
 protected JTree. TreeSelectionRedirector selectionRedirector
Creates a new event and passed it off the selectionListeners.

 o cellEditor
 protected transient TreeCellEditor cellEditor
Editor for the entries.

 o editable
 protected boolean editable
Is the tree editable?

 o largeModel
 protected boolean largeModel
Is the receiver a large model? This is only a suggestion to the UI, not all UIs will implement this.

 o visibleRowCount
 protected int visibleRowCount
Number of rows to make visible at one time. This is used for the Scrollable interface.

 o CELL_RENDERER_PROPERTY
 public static final String CELL_RENDERER_PROPERTY
Bound property name for cellRenderer.

 o TREE_MODEL_PROPERTY
 public static final String TREE_MODEL_PROPERTY
Bound property name for treeModel.

 o ROOT_VISIBLE_PROPERTY
 public static final String ROOT_VISIBLE_PROPERTY
Bound property name for rootVisible.

 o SHOWS_ROOT_HANDLES_PROPERTY
 public static final String SHOWS_ROOT_HANDLES_PROPERTY
Bound property name for showsRootHandles.

 o ROW_HEIGHT_PROPERTY
 public static final String ROW_HEIGHT_PROPERTY
Bound property name for rowHeight.

 o CELL_EDITOR_PROPERTY
 public static final String CELL_EDITOR_PROPERTY
Bound property name for cellEditor.

 o EDITABLE_PROPERTY
 public static final String EDITABLE_PROPERTY
Bound property name for editable.

 o LARGE_MODEL_PROPERTY
 public static final String LARGE_MODEL_PROPERTY
Bound property name for largeModel.

 o SELECTION_MODEL_PROPERTY
 public static final String SELECTION_MODEL_PROPERTY
Bound property name for selectionModel.

 o VISIBLE_ROW_COUNT_PROPERTY
 public static final String VISIBLE_ROW_COUNT_PROPERTY
Bound property name for visibleRowCount.

Constructors

 o JTree
 public JTree()
Returns a JTree with a sample model.

 o JTree
 public JTree(Object value[])
Returns a JTree with each element of value as the child of a root node.

 o JTree
 public JTree(Vector value)
Returns a JTree with each element of value as the child of a root node.

 o JTree
 public JTree(Hashtable value)
Returns a JTree with each element of value as the child of a root node.

 o JTree
 public JTree(TreeNode root)
Returns a JTree with an instance of JTreeModel as its data model, rooted at root and asksAllowsChildren false.

 o JTree
 public JTree(TreeNode root,
              boolean asksAllowsChildren)
Returns a JTree with an instance of JTreeModel as its data model. asksAllowsChildren is passed into the constructore of JTreeModel which will determine how JTreeModel tests for leafness. If asksAllowsChildren is true leafness is determined by messaging getAllowsChildren, otherwise isLeaf is messaged.

 o JTree
 public JTree(TreeModel newModel)
Returns an instance of JTree using the TreeModel newModel.

Methods

 o getDefaultTreeModel
 protected static TreeModel getDefaultTreeModel()
Creates and returns a sample TreeModel. Used primarily for beanbuilders. to show something interesting.

 o createTreeModel
 protected static TreeModel createTreeModel(Object value)
Returns a TreeModel wrapping the passed in object value.

 o getUI
 public TreeUI getUI()
Returns the TreeUI that is providing the current look and feel.

 o setUI
 public void setUI(TreeUI ui)
Sets the TreeUI that will provide the current look and feel.

 o updateUI
 public void updateUI()
Called to replace the UI with the latest version from the default UIFactory.

Overrides:
updateUI in class JComponent
 o getUIClassID
 public String getUIClassID()
Returns:
"TreeUI"
Overrides:
getUIClassID in class JComponent
See Also:
getUIClassID, getUI
 o getCellRenderer
 public TreeCellRenderer getCellRenderer()
Returns the current TreeCellRenderer that is rendering each cell.

 o setCellRenderer
 public void setCellRenderer(TreeCellRenderer x)
Sets the TreeCellRenderer that will be used to draw each cell.

 o setEditable
 public void setEditable(boolean flag)
Sets the tree to being editable based on flag. Fires a property change if flag is different that the current editability.

 o isEditable
 public boolean isEditable()
Returns true if the tree is editable.

 o setCellEditor
 public void setCellEditor(TreeCellEditor cellEditor)
Sets the cell editor to cellEditor. A null value implies that the tree can not be edited. If this signifies a change in the cellEditor and propertyChange method is invoked on all the listeners.

 o getCellEditor
 public TreeCellEditor getCellEditor()
Returns the editor used to edit entries in the tree. Null implies the tree can not be edited.

 o getModel
 public TreeModel getModel()
Returns the TreeModel that is providing the data.

 o setModel
 public void setModel(TreeModel newModel)
Sets the TreeModel that will provide the data.

 o isRootVisible
 public boolean isRootVisible()
Returns true if the root node from the TreeModel is currently visible.

 o setRootVisible
 public void setRootVisible(boolean rootVisible)
Sets, based on rootVisible, whether or not the root node from the TreeModel is visible.

 o setShowsRootHandles
 public void setShowsRootHandles(boolean newValue)
Sets whether or not the root handles are to be displayed.

 o getShowsRootHandles
 public boolean getShowsRootHandles()
Returns true if handles for the root nodes are displayed.

 o setRowHeight
 public void setRowHeight(int rowHeight)
Sets the height of each to be rowHeight. If rowHeight is less than or equal to zero the current cell renderer will be queried for each rows height.

 o getRowHeight
 public int getRowHeight()
Returns the height of each row. If returned value is less than or equal to 0 the height for each row is determined by the renderer.

 o isFixedRowHeight
 public boolean isFixedRowHeight()
Returns true if the height of each row is a fixed size.

 o setLargeModel
 public void setLargeModel(boolean newValue)
Set the receiver to being a larged model based on newValue. Not all UIs will implement this. This will fire a property change for the LARGE_MODEL_PROPERTY.

 o isLargeModel
 public boolean isLargeModel()
Returns true if the receiver is configured for a large model.

 o convertValueToText
 public String convertValueToText(Object value,
                                  boolean selected,
                                  boolean expanded,
                                  boolean leaf,
                                  int row,
                                  boolean hasFocus)
This is called by the renderers to convert the passed in value into text. The default implementation of this returns value.toString(). If you would like to now use this, this is the method to subclass to do this.

 o getRowCount
 public int getRowCount()
Returns the number of rows that are currently being displayed.

 o setSelectionPath
 public void setSelectionPath(TreePath path)
Sets to selection to the value identified by path. If any component of path is not currently visible it will be made visible.

 o setSelectionPaths
 public void setSelectionPaths(TreePath paths[])
Sets the selection to paths. If any component in any of the paths is not currently visible it will be made visible.

 o setSelectionRow
 public void setSelectionRow(int row)
Sets the selection to the path at index row.

 o setSelectionRows
 public void setSelectionRows(int rows[])
The selection is set to the paths for the items at each of the rows in rows.

 o addSelectionPath
 public void addSelectionPath(TreePath path)
Adds the path identified by path to the current selection. If any component of path isn't visible, it will be made visible.

 o addSelectionPaths
 public void addSelectionPaths(TreePath paths[])
Adds each path in paths to the current selection. If any component of any of the paths isn't visible, it will be made visible.

 o addSelectionRow
 public void addSelectionRow(int row)
Adds the paths at each of the rows in rows to the current selection.

 o addSelectionRows
 public void addSelectionRows(int rows[])
Adds the paths at each of the rows in rows to the current selection.

 o getLastSelectedPathComponent
 public Object getLastSelectedPathComponent()
Returns the last path component in the selection.

 o getSelectionPath
 public TreePath getSelectionPath()
Returns the path to the first selected value, or null if nothing is currently selected.

 o getSelectionPaths
 public TreePath[] getSelectionPaths()
Returns the path of the selected values, or null if nothing is current selected.

 o getSelectionRows
 public int[] getSelectionRows()
Returns all of the currently selected rows.

 o getSelectionCount
 public int getSelectionCount()
Returns the number of nodes selected.

 o getMinSelectionRow
 public int getMinSelectionRow()
Gets the first selected row.

 o getMaxSelectionRow
 public int getMaxSelectionRow()
Gets the last selected row.

 o getLeadSelectionRow
 public int getLeadSelectionRow()
Returns the lead selection index. That is the last index that was added.

 o getLeadSelectionPath
 public TreePath getLeadSelectionPath()
Returns the last path that was added.

 o isPathSelected
 public boolean isPathSelected(TreePath path)
Returns true if item identified by path is currently selected.

 o isRowSelected
 public boolean isRowSelected(int row)
Returns true if the row identitifed by row is selected.

 o isExpanded
 public boolean isExpanded(TreePath path)
Returns true if the value identified by path is currently expanded, this will return false if any of the values in path are currently not being displayed.

 o isExpanded
 public boolean isExpanded(int row)
Returns true if the value identified by row is currently expanded.

 o isCollapsed
 public boolean isCollapsed(TreePath path)
Returns true if the value identified by path is currently collapsed, this will return false if any of the values in path are currently not being displayed.

 o isCollapsed
 public boolean isCollapsed(int row)
Returns true if the value identified by row is currently collapsed.

 o makeVisible
 public void makeVisible(TreePath path)
Insures that the value identified by path is currently visible.

 o isVisible
 public boolean isVisible(TreePath path)
Returns true if the value identified by path is currently visible, false otherwise.

 o getPathBounds
 public Rectangle getPathBounds(TreePath path)
Returns the Rectangle that the last item in path will be drawn into. Will return null if any component in path is currently valid.

 o getRowBounds
 public Rectangle getRowBounds(int row)
Returns the Rectangle that the item identified by row will be drawn into. Will return null if any component in path is currently valid.

 o scrollPathToVisible
 public void scrollPathToVisible(TreePath path)
Makes sure all the path components in path are expanded (accept for the last path component) and tries to scroll the resulting path to be visible.

 o scrollRowToVisible
 public void scrollRowToVisible(int row)
Scrolls the item identified by row to be visible. This will only work if the JTree is contained in a JSrollPane.

 o getPathForRow
 public TreePath getPathForRow(int row)
Returns the path for passed in row. If row is not visible null is returned.

 o getRowForPath
 public int getRowForPath(TreePath path)
Returns the row that the last item identified in path is visible at. Will return -1 if any of the elements in path are not currently visible.

 o expandPath
 public void expandPath(TreePath path)
Insures that the last item identified in path is expanded and visible.

 o expandRow
 public void expandRow(int row)
Insures that the item identified by row is expanded.

 o collapsePath
 public void collapsePath(TreePath path)
Insures that the last item identified in path is collapsed and visible.

 o collapseRow
 public void collapseRow(int row)
Insures that the item identified by row is collapsed.

 o getPathForLocation
 public TreePath getPathForLocation(int x,
                                    int y)
Returns the path for the given location.

 o getRowForLocation
 public int getRowForLocation(int x,
                              int y)
Returns the row for the passed in location. If closestRowForLocation returns a row, but the x location passed in is not inside the bounds of the given row -1 will be returned.

 o getClosestPathForLocation
 public TreePath getClosestPathForLocation(int x,
                                           int y)
Returns the path to the node that is closest to x,y. If there is nothing currently visible, or no model, this will return null, otherwise it'll always return a valid path. If you need to test if the returned object is exactly at x, y you should get the bounds for the returned path and test x, y against that.

See Also:
getPathForLocation
 o getClosestRowForLocation
 public int getClosestRowForLocation(int x,
                                     int y)
Returns the row to the node that is closest to x,y. If there is nothing currently visible this will return -1, otherwise it'll always return a valid row. If you need to test if the returned object is exactly at x, y you should get the bounds for the returned row and test x, y against that.

 o isEditing
 public boolean isEditing()
Returns true if the tree is being edited. The item that is being edited can be returned by getSelectionPath().

 o stopEditing
 public boolean stopEditing()
Stops the current editing session. This has no effect if the tree isn't being edited.

 o startEditingAtPath
 public void startEditingAtPath(TreePath path)
Selects the last item in path and tries to edit it. Editing will fail if the CellEditor won't allow it for the selected item.

 o getEditingPath
 public TreePath getEditingPath()
Returns the path to the element that is being edited.

 o setSelectionModel
 public void setSelectionModel(TreeSelectionModel selectionModel)
Sets the selection model to selectionModel. If selectionModel is null a selection model that does not allow anything to be selected will be used.

 o getSelectionModel
 public TreeSelectionModel getSelectionModel()
Returns the model for selections. This should always return a non null value. If you don't want to allow anything to be selected set the selection model to null, this will force an empty selection model to be used.

 o getPathBetweenRows
 protected TreePath[] getPathBetweenRows(int index0,
                                         int index1)
Returns JTreePath instances representing the path between index0 and index1 (including index1). Will return null if there is no tree.

 o setSelectionInterval
 public void setSelectionInterval(int index0,
                                  int index1)
Sets the selection to the paths of the nodes between index0 and index1.

 o addSelectionInterval
 public void addSelectionInterval(int index0,
                                  int index1)
Adds the paths between index0 and index1 to the selection.

 o removeSelectionInterval
 public void removeSelectionInterval(int index0,
                                     int index1)
Removes the paths between index0 and index1 from the selection.

 o removeSelectionPath
 public void removeSelectionPath(TreePath path)
Removes the path identified by path from the current selection.

 o removeSelectionPaths
 public void removeSelectionPaths(TreePath paths[])
Removes the paths, identified by paths, from the current selection.

 o removeSelectionRow
 public void removeSelectionRow(int row)
Removes the path at the index row from the current selection.

 o removeSelectionRows
 public void removeSelectionRows(int rows[])
Removes the paths that are selected at each of the indices in rows.

 o clearSelection
 public void clearSelection()
Clears the selection.

 o isSelectionEmpty
 public boolean isSelectionEmpty()
Returns true if the selection is currently empty.

 o addTreeExpansionListener
 public void addTreeExpansionListener(TreeExpansionListener tel)
Adds tel as interested in recieving TreeExpansion events.

 o removeTreeExpansionListener
 public void removeTreeExpansionListener(TreeExpansionListener tel)
Removes tel as being interested in recieving TreeExpansion events.

 o fireTreeExpanded
 public void fireTreeExpanded(TreePath path)
 o fireTreeCollapsed
 public void fireTreeCollapsed(TreePath path)
 o addTreeSelectionListener
 public void addTreeSelectionListener(TreeSelectionListener tsl)
Adds tsl as interested in recieving TreeSelection events.

 o removeTreeSelectionListener
 public void removeTreeSelectionListener(TreeSelectionListener tsl)
Removes tsl as being interested in recieving TreeSelection events.

 o fireValueChanged
 protected void fireValueChanged(TreeSelectionEvent e)
 o 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)

 o setVisibleRowCount
 public void setVisibleRowCount(int newCount)
Sets the number of rows that are to be visible. This will only work if the reciever is contained in a JScrollPane, and will adjust the preferred size and size of that scrollpane.

 o getVisibleRowCount
 public int getVisibleRowCount()
Returns the number of rows that are to be made visible.

 o isOpaque
 public boolean isOpaque()
Returns true if this component is completely opaque.

Overrides:
isOpaque in class JComponent
 o getPreferredScrollableViewportSize
 public Dimension getPreferredScrollableViewportSize()
Returns the preferred viewable size of a JTree. The height is determined from getVisibleRowCount and the width is the current preferred width.

 o getScrollableUnitIncrement
 public int getScrollableUnitIncrement(Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Returns the amount to increment when scrolling. The amount is will be the amount of the first visible row that isn't visible, or if it is totally visible, the height of the previous or next row.

Parameters:
visibleRect - The view area visible within the viewport
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - Less than zero to scroll up/left, greater than zero for down/right.
Returns:
The "unit" increment for scrolling in the specified direction
See Also:
setUnitIncrement
 o getScrollableBlockIncrement
 public int getScrollableBlockIncrement(Rectangle visibleRect,
                                        int orientation,
                                        int direction)
Returns the amount for a block inrecment, which is the height or width of visibleRect, based on orientation.

Parameters:
visibleRect - The view area visible within the viewport
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - Less than zero to scroll up/left, greater than zero for down/right.
Returns:
The "block" increment for scrolling in the specified direction.
See Also:
setBlockIncrement
 o getScrollableTracksViewportWidth
 public boolean getScrollableTracksViewportWidth()
Returns false.

 o getScrollableTracksViewportHeight
 public boolean getScrollableTracksViewportHeight()
Returns false.


All Packages  Class Hierarchy  This Package  Previous  Next  Index