All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.swing.JTree
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.swing.JComponent
|
+----java.awt.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());
TreePath 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.
JTree.DynamicUtilTreeNode- DynamicUtilTreeNode can wrap vectors/hashtables/arrays/strings and
create the appropriate children tree nodes as necessary.
JTree.EmptySelectionModel- EmptySelectionModel is a TreeSelectionModel that does not allow
anything to be selected.
JTree.TreeSelectionRedirector- Handles creating a new TreeSelectionEvent with the JTree as the
source and passed it off to all the listeners.
CELL_EDITOR_PROPERTY- Bound property name for cellEditor.
CELL_RENDERER_PROPERTY- Bound property name for cellRenderer.
cellEditor- Editor for the entries.
cellRenderer- The cell used to draw nodes.
editable- Is the tree editable?
EDITABLE_PROPERTY- Bound property name for editable.
LARGE_MODEL_PROPERTY- Bound property name for largeModel.
largeModel- Is the receiver a large model? This is only a suggestion to the
UI, not all UIs will implement this.
ROOT_VISIBLE_PROPERTY- Bound property name for rootVisible.
rootVisible- True if the root node is displayed, false if its children are
the highest visible nodes.
ROW_HEIGHT_PROPERTY- Bound property name for rowHeight.
rowHeight- Height to use for each row.
SELECTION_MODEL_PROPERTY- Bound property name for selectionModel.
selectionModel- Models the set of selected nodes in this tree.
selectionRedirector- Creates a new event and passed it off the selectionListeners.
SHOWS_ROOT_HANDLES_PROPERTY- Bound property name for showsRootHandles.
showsRootHandles- true if there should be handles at the top level.
TREE_MODEL_PROPERTY- Bound property name for treeModel.
treeModel- The model that defines the tree displayed by this object.
VISIBLE_ROW_COUNT_PROPERTY- Bound property name for visibleRowCount.
visibleRowCount- Number of rows to make visible at one time.
JTree()
- Returns a JTree with a sample model.
JTree(Hashtable)
- Returns a JTree with each element of
value
as the
child of a root node.
JTree(Object[])
- Returns a JTree with each element of
value
as the
child of a root node.
JTree(TreeModel)
- Returns an instance of JTree using the TreeModel newModel.
JTree(TreeNode)
- Returns a JTree with an instance of JTreeModel as its data model,
rooted at root and asksAllowsChildren false.
JTree(TreeNode, boolean)
- Returns a JTree with an instance of JTreeModel as its data model.
JTree(Vector)
- Returns a JTree with each element of
value
as the
child of a root node.
addSelectionInterval(int, int)
- Adds the paths between index0 and index1 to the selection.
addSelectionPath(TreePath)
- Adds the path identified by path to the current selection.
addSelectionPaths(TreePath[])
- Adds each path in paths to the current selection.
addSelectionRow(int)
- Adds the paths at each of the rows in rows to the current selection.
addSelectionRows(int[])
- Adds the paths at each of the rows in rows to the current selection.
addTreeExpansionListener(TreeExpansionListener)
- Adds tel as interested in recieving TreeExpansion
events.
addTreeSelectionListener(TreeSelectionListener)
- Adds tsl as interested in recieving TreeSelection
events.
clearSelection()
- Clears the selection.
collapsePath(TreePath)
- Insures that the last item identified in path is collapsed and
visible.
collapseRow(int)
- Insures that the item identified by row is collapsed.
convertValueToText(Object, boolean, boolean, boolean, int, boolean)
- This is called by the renderers to convert the passed in value into
text.
createTreeModel(Object)
- Returns a TreeModel wrapping the passed in object
value
.
expandPath(TreePath)
- Insures that the last item identified in path is expanded and
visible.
expandRow(int)
- Insures that the item identified by row is expanded.
fireTreeCollapsed(TreePath)
-
fireTreeExpanded(TreePath)
-
fireValueChanged(TreeSelectionEvent)
-
getCellEditor()
- Returns the editor used to edit entries in the tree.
getCellRenderer()
- Returns the current TreeCellRenderer that is rendering each
cell.
getClosestPathForLocation(int, int)
- Returns the path to the node that is closest to x,y.
getClosestRowForLocation(int, int)
- Returns the row to the node that is closest to x,y.
getDefaultTreeModel()
- Creates and returns a sample TreeModel.
getEditingPath()
- Returns the path to the element that is being edited.
getLastSelectedPathComponent()
- Returns the last path component in the selection.
getLeadSelectionPath()
- Returns the last path that was added.
getLeadSelectionRow()
- Returns the lead selection index.
getMaxSelectionRow()
- Gets the last selected row.
getMinSelectionRow()
- Gets the first selected row.
getModel()
- Returns the TreeModel that is providing the data.
getPathBetweenRows(int, int)
- Returns JTreePath instances representing the path between index0
and index1 (including index1).
getPathBounds(TreePath)
- Returns the Rectangle that the last item in path will be drawn
into.
getPathForLocation(int, int)
- Returns the path for the given location.
getPathForRow(int)
- Returns the path for passed in row.
getPreferredScrollableViewportSize()
- Returns the preferred viewable size of a JTree.
getRowBounds(int)
- Returns the Rectangle that the item identified by row will be
drawn into.
getRowCount()
- Returns the number of rows that are currently being displayed.
getRowForLocation(int, int)
- Returns the row for the passed in location.
getRowForPath(TreePath)
- Returns the row that the last item identified in path is visible
at.
getRowHeight()
- Returns the height of each row.
getScrollableBlockIncrement(Rectangle, int, int)
- Returns the amount for a block inrecment, which is the height or
width of
visibleRect
, based on orientation
.
getScrollableTracksViewportHeight()
- Returns false.
getScrollableTracksViewportWidth()
- Returns false.
getScrollableUnitIncrement(Rectangle, int, int)
- Returns the amount to increment when scrolling.
getSelectionCount()
- Returns the number of nodes selected.
getSelectionModel()
- Returns the model for selections.
getSelectionPath()
- Returns the path to the first selected value, or null if
nothing is currently selected.
getSelectionPaths()
- Returns the path of the selected values, or null if nothing is
current selected.
getSelectionRows()
- Returns all of the currently selected rows.
getShowsRootHandles()
- Returns true if handles for the root nodes are displayed.
getUI()
- Returns the TreeUI that is providing the current look and
feel.
getUIClassID()
-
getVisibleRowCount()
- Returns the number of rows that are to be made visible.
isCollapsed(int)
- Returns true if the value identified by row is currently collapsed.
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.
isEditable()
- Returns true if the tree is editable.
isEditing()
- Returns true if the tree is being edited.
isExpanded(int)
- Returns true if the value identified by row is currently expanded.
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.
isFixedRowHeight()
- Returns true if the height of each row is a fixed size.
isLargeModel()
- Returns true if the receiver is configured for a large model.
isOpaque()
- Returns true if this component is completely opaque.
isPathSelected(TreePath)
- Returns true if item identified by path is currently selected.
isRootVisible()
- Returns true if the root node from the TreeModel is currently
visible.
isRowSelected(int)
- Returns true if the row identitifed by row is selected.
isSelectionEmpty()
- Returns true if the selection is currently empty.
isVisible(TreePath)
- Returns true if the value identified by path is currently visible,
false otherwise.
makeVisible(TreePath)
- Insures that the value identified by path is currently visible.
removeSelectionInterval(int, int)
- Removes the paths between index0 and index1 from the selection.
removeSelectionPath(TreePath)
- Removes the path identified by path from the current selection.
removeSelectionPaths(TreePath[])
- Removes the paths, identified by paths, from the current selection.
removeSelectionRow(int)
- Removes the path at the index
row
from the current
selection.
removeSelectionRows(int[])
- Removes the paths that are selected at each of the
indices in
rows
.
removeTreeExpansionListener(TreeExpansionListener)
- Removes tel as being interested in recieving TreeExpansion
events.
removeTreeSelectionListener(TreeSelectionListener)
- Removes tsl as being interested in recieving TreeSelection
events.
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.
scrollRowToVisible(int)
- Scrolls the item identified by row to be visible.
setCellEditor(TreeCellEditor)
- Sets the cell editor to cellEditor.
setCellRenderer(TreeCellRenderer)
- Sets the TreeCellRenderer that will be used to draw each cell.
setEditable(boolean)
- Sets the tree to being editable based on flag.
setLargeModel(boolean)
- Set the receiver to being a larged model based on
newValue
.
setModel(TreeModel)
- Sets the TreeModel that will provide the data.
setRootVisible(boolean)
- Sets, based on rootVisible, whether or not the root node from
the TreeModel is visible.
setRowHeight(int)
- Sets the height of each to be rowHeight.
setSelectionInterval(int, int)
- Sets the selection to the paths of the nodes between index0 and
index1.
setSelectionModel(TreeSelectionModel)
- Sets the selection model to
selectionModel
.
setSelectionPath(TreePath)
- Sets to selection to the value identified by path.
setSelectionPaths(TreePath[])
- Sets the selection to paths.
setSelectionRow(int)
- Sets the selection to the path at index
row
.
setSelectionRows(int[])
- The selection is set to the paths for the items at each of the rows
in rows.
setShowsRootHandles(boolean)
- Sets whether or not the root handles are to be displayed.
setUI(TreeUI)
- Sets the TreeUI that will provide the current look and feel.
setVisibleRowCount(int)
- Sets the number of rows that are to be visible.
startEditingAtPath(TreePath)
- Selects the last item in path and tries to edit it.
stopEditing()
- Stops the current editing session.
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)
updateUI()
- Called to replace the UI with the latest version from the
default UIFactory.
treeModel
protected transient TreeModel treeModel
- The model that defines the tree displayed by this object.
selectionModel
protected transient TreeSelectionModel selectionModel
- Models the set of selected nodes in this tree.
rootVisible
protected boolean rootVisible
- True if the root node is displayed, false if its children are
the highest visible nodes.
cellRenderer
protected transient TreeCellRenderer cellRenderer
- The cell used to draw nodes. If null, the UI uses a default
cellRenderer.
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.
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.
selectionRedirector
protected JTree.TreeSelectionRedirector selectionRedirector
- Creates a new event and passed it off the selectionListeners.
cellEditor
protected transient TreeCellEditor cellEditor
- Editor for the entries.
editable
protected boolean editable
- Is the tree editable?
largeModel
protected boolean largeModel
- Is the receiver a large model? This is only a suggestion to the
UI, not all UIs will implement this.
visibleRowCount
protected int visibleRowCount
- Number of rows to make visible at one time. This is used for
the Scrollable interface.
CELL_RENDERER_PROPERTY
public static final String CELL_RENDERER_PROPERTY
- Bound property name for cellRenderer.
TREE_MODEL_PROPERTY
public static final String TREE_MODEL_PROPERTY
- Bound property name for treeModel.
ROOT_VISIBLE_PROPERTY
public static final String ROOT_VISIBLE_PROPERTY
- Bound property name for rootVisible.
SHOWS_ROOT_HANDLES_PROPERTY
public static final String SHOWS_ROOT_HANDLES_PROPERTY
- Bound property name for showsRootHandles.
ROW_HEIGHT_PROPERTY
public static final String ROW_HEIGHT_PROPERTY
- Bound property name for rowHeight.
CELL_EDITOR_PROPERTY
public static final String CELL_EDITOR_PROPERTY
- Bound property name for cellEditor.
EDITABLE_PROPERTY
public static final String EDITABLE_PROPERTY
- Bound property name for editable.
LARGE_MODEL_PROPERTY
public static final String LARGE_MODEL_PROPERTY
- Bound property name for largeModel.
SELECTION_MODEL_PROPERTY
public static final String SELECTION_MODEL_PROPERTY
- Bound property name for selectionModel.
VISIBLE_ROW_COUNT_PROPERTY
public static final String VISIBLE_ROW_COUNT_PROPERTY
- Bound property name for visibleRowCount.
JTree
public JTree()
- Returns a JTree with a sample model.
JTree
public JTree(Object[] value)
- Returns a JTree with each element of
value
as the
child of a root node.
JTree
public JTree(Vector value)
- Returns a JTree with each element of
value
as the
child of a root node.
JTree
public JTree(Hashtable value)
- Returns a JTree with each element of
value
as the
child of a root node.
JTree
public JTree(TreeNode root)
- Returns a JTree with an instance of JTreeModel as its data model,
rooted at root and asksAllowsChildren false.
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.
JTree
public JTree(TreeModel newModel)
- Returns an instance of JTree using the TreeModel newModel.
getDefaultTreeModel
protected static TreeModel getDefaultTreeModel()
- Creates and returns a sample TreeModel. Used primarily for beanbuilders.
to show something interesting.
createTreeModel
protected static TreeModel createTreeModel(Object value)
- Returns a TreeModel wrapping the passed in object
value
.
getUI
public TreeUI getUI()
- Returns the TreeUI that is providing the current look and
feel.
setUI
public void setUI(TreeUI ui)
- Sets the TreeUI that will provide the current look and feel.
updateUI
public void updateUI()
- Called to replace the UI with the latest version from the
default UIFactory.
- Overrides:
- updateUI in class JComponent
getUIClassID
public String getUIClassID()
- Returns:
- "TreeUI"
- Overrides:
- getUIClassID in class JComponent
- See Also:
- getUIClassID, getUI
getCellRenderer
public TreeCellRenderer getCellRenderer()
- Returns the current TreeCellRenderer that is rendering each
cell.
setCellRenderer
public void setCellRenderer(TreeCellRenderer x)
- Sets the TreeCellRenderer that will be used to draw each cell.
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.
isEditable
public boolean isEditable()
- Returns true if the tree is editable.
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.
getCellEditor
public TreeCellEditor getCellEditor()
- Returns the editor used to edit entries in the tree. Null implies
the tree can not be edited.
getModel
public TreeModel getModel()
- Returns the TreeModel that is providing the data.
setModel
public void setModel(TreeModel newModel)
- Sets the TreeModel that will provide the data.
isRootVisible
public boolean isRootVisible()
- Returns true if the root node from the TreeModel is currently
visible.
setRootVisible
public void setRootVisible(boolean rootVisible)
- Sets, based on rootVisible, whether or not the root node from
the TreeModel is visible.
setShowsRootHandles
public void setShowsRootHandles(boolean newValue)
- Sets whether or not the root handles are to be displayed.
getShowsRootHandles
public boolean getShowsRootHandles()
- Returns true if handles for the root nodes are displayed.
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.
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.
isFixedRowHeight
public boolean isFixedRowHeight()
- Returns true if the height of each row is a fixed size.
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.
isLargeModel
public boolean isLargeModel()
- Returns true if the receiver is configured for a large model.
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.
getRowCount
public int getRowCount()
- Returns the number of rows that are currently being displayed.
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.
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.
setSelectionRow
public void setSelectionRow(int row)
- Sets the selection to the path at index
row
.
setSelectionRows
public void setSelectionRows(int[] rows)
- The selection is set to the paths for the items at each of the rows
in rows.
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.
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.
addSelectionRow
public void addSelectionRow(int row)
- Adds the paths at each of the rows in rows to the current selection.
addSelectionRows
public void addSelectionRows(int[] rows)
- Adds the paths at each of the rows in rows to the current selection.
getLastSelectedPathComponent
public Object getLastSelectedPathComponent()
- Returns the last path component in the selection.
getSelectionPath
public TreePath getSelectionPath()
- Returns the path to the first selected value, or null if
nothing is currently selected.
getSelectionPaths
public TreePath[] getSelectionPaths()
- Returns the path of the selected values, or null if nothing is
current selected.
getSelectionRows
public int[] getSelectionRows()
- Returns all of the currently selected rows.
getSelectionCount
public int getSelectionCount()
- Returns the number of nodes selected.
getMinSelectionRow
public int getMinSelectionRow()
- Gets the first selected row.
getMaxSelectionRow
public int getMaxSelectionRow()
- Gets the last selected row.
getLeadSelectionRow
public int getLeadSelectionRow()
- Returns the lead selection index. That is the last index that was
added.
getLeadSelectionPath
public TreePath getLeadSelectionPath()
- Returns the last path that was added.
isPathSelected
public boolean isPathSelected(TreePath path)
- Returns true if item identified by path is currently selected.
isRowSelected
public boolean isRowSelected(int row)
- Returns true if the row identitifed by row is selected.
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.
isExpanded
public boolean isExpanded(int row)
- Returns true if the value identified by row is currently expanded.
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.
isCollapsed
public boolean isCollapsed(int row)
- Returns true if the value identified by row is currently collapsed.
makeVisible
public void makeVisible(TreePath path)
- Insures that the value identified by path is currently visible.
isVisible
public boolean isVisible(TreePath path)
- Returns true if the value identified by path is currently visible,
false otherwise.
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.
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.
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.
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.
getPathForRow
public TreePath getPathForRow(int row)
- Returns the path for passed in row. If row is not visible
null is returned.
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.
expandPath
public void expandPath(TreePath path)
- Insures that the last item identified in path is expanded and
visible.
expandRow
public void expandRow(int row)
- Insures that the item identified by row is expanded.
collapsePath
public void collapsePath(TreePath path)
- Insures that the last item identified in path is collapsed and
visible.
collapseRow
public void collapseRow(int row)
- Insures that the item identified by row is collapsed.
getPathForLocation
public TreePath getPathForLocation(int x,
int y)
- Returns the path for the given location.
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.
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
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.
isEditing
public boolean isEditing()
- Returns true if the tree is being edited. The item that is being
edited can be returned by getSelectionPath().
stopEditing
public boolean stopEditing()
- Stops the current editing session. This has no effect if the
tree isn't being edited.
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.
getEditingPath
public TreePath getEditingPath()
- Returns the path to the element that is being edited.
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.
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.
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.
setSelectionInterval
public void setSelectionInterval(int index0,
int index1)
- Sets the selection to the paths of the nodes between index0 and
index1.
addSelectionInterval
public void addSelectionInterval(int index0,
int index1)
- Adds the paths between index0 and index1 to the selection.
removeSelectionInterval
public void removeSelectionInterval(int index0,
int index1)
- Removes the paths between index0 and index1 from the selection.
removeSelectionPath
public void removeSelectionPath(TreePath path)
- Removes the path identified by path from the current selection.
removeSelectionPaths
public void removeSelectionPaths(TreePath[] paths)
- Removes the paths, identified by paths, from the current selection.
removeSelectionRow
public void removeSelectionRow(int row)
- Removes the path at the index
row
from the current
selection.
removeSelectionRows
public void removeSelectionRows(int[] rows)
- Removes the paths that are selected at each of the
indices in
rows
.
clearSelection
public void clearSelection()
- Clears the selection.
isSelectionEmpty
public boolean isSelectionEmpty()
- Returns true if the selection is currently empty.
addTreeExpansionListener
public void addTreeExpansionListener(TreeExpansionListener tel)
- Adds tel as interested in recieving TreeExpansion
events.
removeTreeExpansionListener
public void removeTreeExpansionListener(TreeExpansionListener tel)
- Removes tel as being interested in recieving TreeExpansion
events.
fireTreeExpanded
public void fireTreeExpanded(TreePath path)
fireTreeCollapsed
public void fireTreeCollapsed(TreePath path)
addTreeSelectionListener
public void addTreeSelectionListener(TreeSelectionListener tsl)
- Adds tsl as interested in recieving TreeSelection
events.
removeTreeSelectionListener
public void removeTreeSelectionListener(TreeSelectionListener tsl)
- Removes tsl as being interested in recieving TreeSelection
events.
fireValueChanged
protected void fireValueChanged(TreeSelectionEvent e)
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)
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.
getVisibleRowCount
public int getVisibleRowCount()
- Returns the number of rows that are to be made visible.
isOpaque
public boolean isOpaque()
- Returns true if this component is completely opaque.
- Overrides:
- isOpaque in class JComponent
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.
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
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
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()
- Returns false.
getScrollableTracksViewportHeight
public boolean getScrollableTracksViewportHeight()
- Returns false.
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature