Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing.plaf.basic
Class BasicTreeUI

    java.lang.Object
      |
      +--javax.swing.plaf.ComponentUI
            |
            +--javax.swing.plaf.TreeUI
                  |
                  +--javax.swing.plaf.basic.BasicTreeUI

Direct Known Subclasses:
  MetalTreeUI

public class BasicTreeUI
extends TreeUI

The basic L&F for a hierarchical data structure.

Inner Class Summary
`class` | `BasicTreeUI.CellEditorHandler` Listener responsible for getting cell editing events and updating the tree accordingly.
`class` | `BasicTreeUI.ComponentHandler` Updates the preferred size when scrolling (if necessary).
`class` | `BasicTreeUI.FocusHandler` Repaints the lead selection row when focus is lost/gained.
`class` | `BasicTreeUI.KeyHandler` This is used to get mutliple key down events to appropriately generate events.
`class` | `BasicTreeUI.MouseHandler` TreeMouseListener is responsible for updating the selection based on mouse events.
`class` | `BasicTreeUI.MouseInputHandler` MouseInputHandler handles passing all mouse events, including mouse motion events, until the mouse is released to the destination it is constructed with.
`class` | `BasicTreeUI.NodeDimensionsHandler` Class responsible for getting size of node, method is forwarded to BasicTreeUI method.
`class` | `BasicTreeUI.PropertyChangeHandler` PropertyChangeListener for the tree.
`class` | `BasicTreeUI.SelectionModelPropertyChangeHandler` Listener on the TreeSelectionModel, resets the row selection if any of the properties of the model change.
`class` | `BasicTreeUI.TreeCancelEditingAction` ActionListener that invokes cancelEditing when action performed.
`class` | `BasicTreeUI.TreeExpansionHandler` Updates the TreeState in response to nodes expanding/collapsing.
`class` | `BasicTreeUI.TreeHomeAction` TreeHomeAction is used to handle end/home actions.
`class` | `BasicTreeUI.TreeIncrementAction` TreeIncrementAction is used to handle up/down actions.
`class` | `BasicTreeUI.TreeModelHandler` Forwards all TreeModel events to the TreeState.
`class` | `BasicTreeUI.TreePageAction` TreePageAction handles page up and page down events.
`class` | `BasicTreeUI.TreeSelectionHandler` Listens for changes in the selection model and updates the display accordingly.
`class` | `BasicTreeUI.TreeToggleAction` For the first selected row expandedness will be toggled.
`class` | `BasicTreeUI.TreeTraverseAction` TreeTraverseAction is the action used for left/right keys.

Field Summary
`protected TreeCellEditor` | `cellEditor` Editor for the tree.
`protected Icon` | `collapsedIcon`
`protected boolean` | `createdCellEditor` Set to true if editor that is currently in the tree was created by this instance.
`protected boolean` | `createdRenderer` Set to true if the renderer that is currently in the tree was created by this instance.
`protected TreeCellRenderer` | `currentCellRenderer` Renderer that is being used to do the actual cell drawing.
`protected int` | `depthOffset` How much the depth should be offset to properly calculate x locations.
`protected java.util.Hashtable` | `drawingCache` Used for minimizing the drawing of vertical lines.
`protected java.awt.Component` | `editingComponent` When editing, this will be the Component that is doing the actual editing.
`protected TreePath` | `editingPath` Path that is being edited.
`protected int` | `editingRow` Row that is being edited.
`protected boolean` | `editorHasDifferentSize` Set to true if the editor has a different size than the renderer.
`protected Icon` | `expandedIcon`
`protected boolean` | `largeModel` True if doing optimizations for a largeModel.
`protected int` | `lastSelectedRow` Index of the row that was last selected.
`protected int` | `leftChildIndent` Distance between left margin and where verical dashes will be drawn.
`protected AbstractLayoutCache.NodeDimensions` | `nodeDimensions` Reponsible for telling the TreeState the size needed for a node.
`protected java.awt.Dimension` | `preferredMinSize` Minimum preferred size.
`protected java.awt.Dimension` | `preferredSize` Size needed to completely display all the nodes.
`protected CellRendererPane` | `rendererPane` Used to paint the TreeCellRenderer.
`protected int` | `rightChildIndent` Distance to add to leftChildIndent to determine where cell contents will be drawn.
`protected boolean` | `stopEditingInCompleteEditing` Set to false when editing and shouldSelectCell() returns true meaning the node should be selected before editing, used in completeEditing.
`protected int` | `totalChildIndent` Total distance that will be indented.
`protected JTree` | `tree` Component that we're going to be drawing into.
`protected TreeModel` | `treeModel` Used to determine what to display.
`protected TreeSelectionModel` | `treeSelectionModel` Model maintaing the selection.
`protected AbstractLayoutCache` | `treeState` Object responsible for handling sizing and expanded issues.
`protected boolean` | `validCachedPreferredSize` Is the preferredSize valid?

Constructor Summary
`BasicTreeUI()`

Method Summary
`void` | `cancelEditing(JTree tree)` Cancels the current editing session.
`protected void` | `checkForClickInExpandControl(TreePath path, int mouseX, int mouseY)` If the `mouseX` and `mouseY` are in the expand/collapse region of the `row`, this will toggle the row.
`protected void` | `completeEditing()` Messages to stop the editing session.
`protected void` | `completeEditing(boolean messageStop, boolean messageCancel, boolean messageTree)` Stops the editing session.
`protected void` | `completeUIInstall()` Invoked from installUI after all the defaults/listeners have been installed.
`protected void` | `completeUIUninstall()`
`protected void` | `configureLayoutCache()` Resets the TreeState instance based on the tree we're providing the look and feel for.
`protected CellEditorListener` | `createCellEditorListener()` Creates a listener to handle events from the current editor.
`protected CellRendererPane` | `createCellRendererPane()` Returns the renderer pane that renderer components are placed in.
`protected java.awt.event.ComponentListener` | `createComponentListener()` Creates and returns a new ComponentHandler.
`protected TreeCellEditor` | `createDefaultCellEditor()` Creates a default cell editor.
`protected TreeCellRenderer` | `createDefaultCellRenderer()` Returns the default cell renderer that is used to do the stamping of each node.
`protected java.awt.event.FocusListener` | `createFocusListener()` Creates a listener that is responsible for updating the display when focus is lost/gained.
`protected java.awt.event.KeyListener` | `createKeyListener()` Creates the listener reponsible for getting key events from the tree.
`protected AbstractLayoutCache` | `createLayoutCache()` Creates the object responsible for managing what is expanded, as well as the size of nodes.
`protected java.awt.event.MouseListener` | `createMouseListener()` Creates the listener responsible for updating the selection based on mouse events.
`protected AbstractLayoutCache.NodeDimensions` | `createNodeDimensions()` Creates an instance of NodeDimensions that is able to determine the size of a given node in the tree.
`protected java.beans.PropertyChangeListener` | `createPropertyChangeListener()` Creates a listener that is responsible that updates the UI based on how the tree changes.
`protected java.beans.PropertyChangeListener` | `createSelectionModelPropertyChangeListener()` Creates the listener responsible for getting property change events from the selection model.
`protected TreeExpansionListener` | `createTreeExpansionListener()` Creates and returns the object responsible for updating the treestate when nodes expanded state changes.
`protected TreeModelListener` | `createTreeModelListener()` Returns a listener that can update the tree when the model changes.
`protected TreeSelectionListener` | `createTreeSelectionListener()` Creates the listener that updates the display based on selection change methods.
`static ComponentUI` | `createUI(JComponent x)`
`protected void` | `drawCentered(java.awt.Component c, java.awt.Graphics graphics, Icon icon, int x, int y)`
`protected void` | `drawDashedHorizontalLine(java.awt.Graphics g, int y, int x1, int x2)`
`protected void` | `drawDashedVerticalLine(java.awt.Graphics g, int x, int y1, int y2)`
`protected void` | `ensureRowsAreVisible(int beginRow, int endRow)` Ensures that the rows identified by beginRow through endRow are visible.
`protected TreeCellEditor` | `getCellEditor()`
`protected TreeCellRenderer` | `getCellRenderer()` Return currentCellRenderer, which will either be the trees renderer, or defaultCellRenderer, which ever wasn't null.
`TreePath` | `getClosestPathForLocation(JTree tree, int x, int y)` Returns the path to the node that is closest to x,y.
`Icon` | `getCollapsedIcon()`
`TreePath` | `getEditingPath(JTree tree)` Returns the path to the element that is being edited.
`Icon` | `getExpandedIcon()`
`protected java.awt.Color` | `getHashColor()`
`protected int` | `getHorizontalLegBuffer()` The horizontal element of legs between nodes starts at the right of the left-hand side of the child node by default.
`protected TreePath` | `getLastChildPath(TreePath parent)` Returns a path to the last child of `parent`.
`int` | `getLeftChildIndent()`
`java.awt.Dimension` | `getMaximumSize(JComponent c)` Returns the maximum size for this component, which will be the preferred size if the instance is currently in a JTree, or 0, 0.
`java.awt.Dimension` | `getMinimumSize(JComponent c)` Returns the minimum size for this component.
`protected TreeModel` | `getModel()`
`java.awt.Rectangle` | `getPathBounds(JTree tree, TreePath path)` Returns the Rectangle enclosing the label portion that the last item in path will be drawn into.
`TreePath` | `getPathForRow(JTree tree, int row)` Returns the path for passed in row.
`java.awt.Dimension` | `getPreferredMinSize()` Returns the minimum preferred size.
`java.awt.Dimension` | `getPreferredSize(JComponent c)` Returns the preferred size to properly display the tree, this is a cover method for getPreferredSize(c, false).
`java.awt.Dimension` | `getPreferredSize(JComponent c, boolean checkConsistancy)` Returns the preferred size to represent the tree in c.
`int` | `getRightChildIndent()`
`int` | `getRowCount(JTree tree)` Returns the number of rows that are being displayed.
`int` | `getRowForPath(JTree tree, TreePath path)` Returns the row that the last item identified in path is visible at.
`protected int` | `getRowHeight()`
`protected TreeSelectionModel` | `getSelectionModel()`
`protected boolean` | `getShowsRootHandles()`
`protected int` | `getVerticalLegBuffer()` The vertical element of legs between nodes starts at the bottom of the parent node by default.
`protected void` | `handleExpandControlClick(TreePath path, int mouseX, int mouseY)` Messaged when the user clicks the particular row, this invokes toggleExpandState.
`protected void` | `installComponents()` Intalls the subcomponents of the tree, which is the renderer pane.
`protected void` | `installDefaults()`
`protected void` | `installKeyboardActions()`
`protected void` | `installListeners()`
`void` | `installUI(JComponent c)`
`protected boolean` | `isEditable()`
`boolean` | `isEditing(JTree tree)` Returns true if the tree is being edited.
`protected boolean` | `isLargeModel()`
`protected boolean` | `isLeaf(int row)`
`protected boolean` | `isLocationInExpandControl(TreePath path, int mouseX, int mouseY)` Returns true if `mouseX` and `mouseY` fall in the area of row that is used to expand/collapse the node and the node at `row` does not represent a leaf.
`protected boolean` | `isMultiSelectEvent(java.awt.event.MouseEvent event)` Returning true signifies a mouse event on the node should select from the anchor point.
`protected boolean` | `isRootVisible()`
`protected boolean` | `isToggleEvent(java.awt.event.MouseEvent event)` Returning true indicates the row under the mouse should be toggled based on the event.
`protected boolean` | `isToggleSelectionEvent(java.awt.event.MouseEvent event)` Returning true signifies a mouse event on the node should toggle the selection of only the row under mouse.
`void` | `paint(java.awt.Graphics g, JComponent c)`
`protected void` | `paintExpandControl(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, java.awt.Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)` Paints the expand (toggle) part of a row.
`protected void` | `paintHorizontalLine(java.awt.Graphics g, JComponent c, int y, int left, int right)` Paints a horizontal line.
`protected void` | `paintHorizontalPartOfLeg(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, java.awt.Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)` Paints the horizontal part of the leg.
`protected void` | `paintRow(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, java.awt.Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)` Paints the renderer part of a row.
`protected void` | `paintVerticalLine(java.awt.Graphics g, JComponent c, int x, int top, int bottom)` Paints a vertical line.
`protected void` | `paintVerticalPartOfLeg(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, TreePath path)` Paints the vertical part of the leg.
`protected void` | `pathWasCollapsed(TreePath path)` Messaged from the VisibleTreeNode after it has collapsed.
`protected void` | `pathWasExpanded(TreePath path)` Messaged from the VisibleTreeNode after it has been expanded.
`protected void` | `prepareForUIInstall()` Invoked after the `tree` instance variable has been set, but before any defaults/listeners have been installed.
`protected void` | `prepareForUIUninstall()`
`protected void` | `selectPathForEvent(TreePath path, java.awt.event.MouseEvent event)` Messaged to update the selection based on a MouseEvent over a particular row.
`protected void` | `setCellEditor(TreeCellEditor editor)` Sets the cell editor.
`protected void` | `setCellRenderer(TreeCellRenderer tcr)` Sets the TreeCellRenderer to `tcr`.
`void` | `setCollapsedIcon(Icon newG)`
`protected void` | `setEditable(boolean newValue)` Configures the receiver to allow, or not allow, editing.
`void` | `setExpandedIcon(Icon newG)`
`protected void` | `setHashColor(java.awt.Color color)`
`protected void` | `setLargeModel(boolean largeModel)` Updates the componentListener, if necessary.
`void` | `setLeftChildIndent(int newAmount)`
`protected void` | `setModel(TreeModel model)` Sets the TreeModel.
`void` | `setPreferredMinSize(java.awt.Dimension newSize)` Sets the preferred minimum size.
`void` | `setRightChildIndent(int newAmount)`
`protected void` | `setRootVisible(boolean newValue)` Sets the root to being visible.
`protected void` | `setRowHeight(int rowHeight)` Sets the row height, this is forwarded to the treeState.
`protected void` | `setSelectionModel(TreeSelectionModel newLSM)` Resets the selection model.
`protected void` | `setShowsRootHandles(boolean newValue)` Determines whether the node handles are to be displayed.
`protected boolean` | `shouldPaintExpandControl(TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)` Returns true if the expand (toggle) control should be drawn for the specified row.
`protected boolean` | `startEditing(TreePath path, java.awt.event.MouseEvent event)` Will start editing for node if there is a cellEditor and shouldSelectCell returns true. This assumes that path is valid and visible.
`void` | `startEditingAtPath(JTree tree, TreePath path)` Selects the last item in path and tries to edit it.
`boolean` | `stopEditing(JTree tree)` Stops the current editing session.
`protected void` | `toggleExpandState(TreePath path)` Expands path if it is not expanded, or collapses row if it is expanded.
`protected void` | `uninstallComponents()` Uninstalls the renderer pane.
`protected void` | `uninstallDefaults()`
`protected void` | `uninstallKeyboardActions()`
`protected void` | `uninstallListeners()`
`void` | `uninstallUI(JComponent c)`
`protected void` | `updateCachedPreferredSize()` Updates the `preferredSize` instance variable, which is returned from `getPreferredSize()`. The size is determined from the current AbstractLayoutCache.
`protected void` | `updateCellEditor()` Updates the cellEditor based on the editability of the JTree that we're contained in.
`protected void` | `updateDepthOffset()` Updates how much each depth should be offset by.
`protected void` | `updateExpandedDescendants(TreePath path)` Updates the expanded state of all the descendants of `path` by getting the expanded descendants from the tree and forwarding to the tree state.
`protected void` | `updateLayoutCacheExpandedNodes()` Makes all the nodes that are expanded in JTree expanded in LayoutCache.
`protected void` | `updateRenderer()` Messaged from the tree we're in when the renderer has changed.
`protected void` | `updateSize()` Marks the cached size as being invalid, and messages the tree with `treeDidChange`.

Methods inherited from class javax.swing.plaf.ComponentUI
`contains, getAccessibleChild, getAccessibleChildrenCount, update`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### collapsedIcon

    protected transient Icon collapsedIcon

### expandedIcon

    protected transient Icon expandedIcon

### leftChildIndent

    protected int leftChildIndent

  Distance between left margin and where verical dashes will be drawn.

### rightChildIndent

    protected int rightChildIndent

  Distance to add to leftChildIndent to determine where cell contents will be drawn.

### totalChildIndent

    protected int totalChildIndent

  Total distance that will be indented. The sum of leftChildIndent and rightChildIndent.

### preferredMinSize

    protected java.awt.Dimension preferredMinSize

  Minimum preferred size.

### lastSelectedRow

    protected int lastSelectedRow

  Index of the row that was last selected.

### tree

    protected JTree tree

  Component that we're going to be drawing into.

### currentCellRenderer

    protected transient TreeCellRenderer currentCellRenderer

  Renderer that is being used to do the actual cell drawing.

### createdRenderer

    protected boolean createdRenderer

  Set to true if the renderer that is currently in the tree was created by this instance.

### cellEditor

    protected transient TreeCellEditor cellEditor

  Editor for the tree.

### createdCellEditor

    protected boolean createdCellEditor

  Set to true if editor that is currently in the tree was created by this instance.

### stopEditingInCompleteEditing

    protected boolean stopEditingInCompleteEditing

  Set to false when editing and shouldSelectCell() returns true meaning the node should be selected before editing, used in completeEditing.

### rendererPane

    protected CellRendererPane rendererPane

  Used to paint the TreeCellRenderer.

### preferredSize

    protected java.awt.Dimension preferredSize

  Size needed to completely display all the nodes.

### validCachedPreferredSize

    protected boolean validCachedPreferredSize

  Is the preferredSize valid?

### treeState

    protected AbstractLayoutCache treeState

  Object responsible for handling sizing and expanded issues.

### drawingCache

    protected java.util.Hashtable drawingCache

  Used for minimizing the drawing of vertical lines.

### largeModel

    protected boolean largeModel

  True if doing optimizations for a largeModel. Subclasses that don't support this may wish to override createLayoutCache to not return a FixedHeightLayoutCache instance.

### nodeDimensions

    protected AbstractLayoutCache.NodeDimensions nodeDimensions

  Reponsible for telling the TreeState the size needed for a node.

### treeModel

    protected TreeModel treeModel

  Used to determine what to display.

### treeSelectionModel

    protected TreeSelectionModel treeSelectionModel

  Model maintaing the selection.

### depthOffset

    protected int depthOffset

  How much the depth should be offset to properly calculate x locations. This is based on whether or not the root is visible, and if the root handles are visible.

### editingComponent

    protected java.awt.Component editingComponent

  When editing, this will be the Component that is doing the actual editing.

### editingPath

    protected TreePath editingPath

  Path that is being edited.

### editingRow

    protected int editingRow

  Row that is being edited. Should only be referenced if editingComponent is not null.

### editorHasDifferentSize

    protected boolean editorHasDifferentSize

  Set to true if the editor has a different size than the renderer.

Constructor Detail

### BasicTreeUI

    public BasicTreeUI()

Method Detail

### createUI

    public static ComponentUI createUI(JComponent x)

### getHashColor

    protected java.awt.Color getHashColor()

### setHashColor

    protected void setHashColor(java.awt.Color color)

### setLeftChildIndent

    public void setLeftChildIndent(int newAmount)

### getLeftChildIndent

    public int getLeftChildIndent()

### setRightChildIndent

    public void setRightChildIndent(int newAmount)

### getRightChildIndent

    public int getRightChildIndent()

### setExpandedIcon

    public void setExpandedIcon(Icon newG)

### getExpandedIcon

    public Icon getExpandedIcon()

### setCollapsedIcon

    public void setCollapsedIcon(Icon newG)

### getCollapsedIcon

    public Icon getCollapsedIcon()

### setLargeModel

    protected void setLargeModel(boolean largeModel)

  Updates the componentListener, if necessary.

### isLargeModel

    protected boolean isLargeModel()

### setRowHeight

    protected void setRowHeight(int rowHeight)

  Sets the row height, this is forwarded to the treeState.

### getRowHeight

    protected int getRowHeight()

### setCellRenderer

    protected void setCellRenderer(TreeCellRenderer tcr)

  Sets the TreeCellRenderer to `tcr`. This invokes `updateRenderer`.

### getCellRenderer

    protected TreeCellRenderer getCellRenderer()

  Return currentCellRenderer, which will either be the trees renderer, or defaultCellRenderer, which ever wasn't null.

### setModel

    protected void setModel(TreeModel model)

  Sets the TreeModel.

### getModel

    protected TreeModel getModel()

### setRootVisible

    protected void setRootVisible(boolean newValue)

  Sets the root to being visible.

### isRootVisible

    protected boolean isRootVisible()

### setShowsRootHandles

    protected void setShowsRootHandles(boolean newValue)

  Determines whether the node handles are to be displayed.

### getShowsRootHandles

    protected boolean getShowsRootHandles()

### setCellEditor

    protected void setCellEditor(TreeCellEditor editor)

  Sets the cell editor.

### getCellEditor

    protected TreeCellEditor getCellEditor()

### setEditable

    protected void setEditable(boolean newValue)

  Configures the receiver to allow, or not allow, editing.

### isEditable

    protected boolean isEditable()

### setSelectionModel

    protected void setSelectionModel(TreeSelectionModel newLSM)

  Resets the selection model. The appropriate listener are installed on the model.

### getSelectionModel

    protected TreeSelectionModel getSelectionModel()

### getPathBounds

    public java.awt.Rectangle getPathBounds(JTree tree,
                                            TreePath path)

  Returns the Rectangle enclosing the label portion that the last item in path will be drawn into. Will return null if any component in path is currently valid.
  Overrides:
    getPathBounds in class TreeUI

### getPathForRow

    public TreePath getPathForRow(JTree tree,
                                  int row)

  Returns the path for passed in row. If row is not visible null is returned.
  Overrides:
    getPathForRow in class TreeUI

### getRowForPath

    public int getRowForPath(JTree tree,
                             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.
  Overrides:
    getRowForPath in class TreeUI

### getRowCount

    public int getRowCount(JTree tree)

  Returns the number of rows that are being displayed.
  Overrides:
    getRowCount in class TreeUI

### getClosestPathForLocation

    public TreePath getClosestPathForLocation(JTree tree,
                                              int x,
                                              int y)

  Returns the path to the node that is closest to x,y. If there is nothing currently visible 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.
  Overrides:
    getClosestPathForLocation in class TreeUI

### isEditing

    public boolean isEditing(JTree tree)

  Returns true if the tree is being edited. The item that is being edited can be returned by getEditingPath().
  Overrides:
    isEditing in class TreeUI

### stopEditing

    public boolean stopEditing(JTree tree)

  Stops the current editing session. This has no effect if the tree isn't being edited. Returns true if the editor allows the editing session to stop.
  Overrides:
    stopEditing in class TreeUI

### cancelEditing

    public void cancelEditing(JTree tree)

  Cancels the current editing session.
  Overrides:
    cancelEditing in class TreeUI

### startEditingAtPath

    public void startEditingAtPath(JTree tree,
                                   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.
  Overrides:
    startEditingAtPath in class TreeUI

### getEditingPath

    public TreePath getEditingPath(JTree tree)

  Returns the path to the element that is being edited.
  Overrides:
    getEditingPath in class TreeUI

### installUI

    public void installUI(JComponent c)

  Overrides:
    installUI in class ComponentUI

### prepareForUIInstall

    protected void prepareForUIInstall()

  Invoked after the `tree` instance variable has been set, but before any defaults/listeners have been installed.

### completeUIInstall

    protected void completeUIInstall()

  Invoked from installUI after all the defaults/listeners have been installed.

### installDefaults

    protected void installDefaults()

### installListeners

    protected void installListeners()

### installKeyboardActions

    protected void installKeyboardActions()

### installComponents

    protected void installComponents()

  Intalls the subcomponents of the tree, which is the renderer pane.

### createNodeDimensions

    protected AbstractLayoutCache.NodeDimensions createNodeDimensions()

  Creates an instance of NodeDimensions that is able to determine the size of a given node in the tree.

### createPropertyChangeListener

    protected java.beans.PropertyChangeListener createPropertyChangeListener()

  Creates a listener that is responsible that updates the UI based on how the tree changes.

### createMouseListener

    protected java.awt.event.MouseListener createMouseListener()

  Creates the listener responsible for updating the selection based on mouse events.

### createFocusListener

    protected java.awt.event.FocusListener createFocusListener()

  Creates a listener that is responsible for updating the display when focus is lost/gained.

### createKeyListener

    protected java.awt.event.KeyListener createKeyListener()

  Creates the listener reponsible for getting key events from the tree.

### createSelectionModelPropertyChangeListener

    protected java.beans.PropertyChangeListener createSelectionModelPropertyChangeListener()

  Creates the listener responsible for getting property change events from the selection model.

### createTreeSelectionListener

    protected TreeSelectionListener createTreeSelectionListener()

  Creates the listener that updates the display based on selection change methods.

### createCellEditorListener

    protected CellEditorListener createCellEditorListener()

  Creates a listener to handle events from the current editor.

### createComponentListener

    protected java.awt.event.ComponentListener createComponentListener()

  Creates and returns a new ComponentHandler. This is used for the large model to mark the validCachedPreferredSize as invalid when the component moves.

### createTreeExpansionListener

    protected TreeExpansionListener createTreeExpansionListener()

  Creates and returns the object responsible for updating the treestate when nodes expanded state changes.

### createLayoutCache

    protected AbstractLayoutCache createLayoutCache()

  Creates the object responsible for managing what is expanded, as well as the size of nodes.

### createCellRendererPane

    protected CellRendererPane createCellRendererPane()

  Returns the renderer pane that renderer components are placed in.

### createDefaultCellEditor

    protected TreeCellEditor createDefaultCellEditor()

  Creates a default cell editor.

### createDefaultCellRenderer

    protected TreeCellRenderer createDefaultCellRenderer()

  Returns the default cell renderer that is used to do the stamping of each node.

### createTreeModelListener

    protected TreeModelListener createTreeModelListener()

  Returns a listener that can update the tree when the model changes.

### uninstallUI

    public void uninstallUI(JComponent c)

  Overrides:
    uninstallUI in class ComponentUI

### prepareForUIUninstall

    protected void prepareForUIUninstall()

### completeUIUninstall

    protected void completeUIUninstall()

### uninstallDefaults

    protected void uninstallDefaults()

### uninstallListeners

    protected void uninstallListeners()

### uninstallKeyboardActions

    protected void uninstallKeyboardActions()

### uninstallComponents

    protected void uninstallComponents()

  Uninstalls the renderer pane.

### paint

    public void paint(java.awt.Graphics g,
                      JComponent c)

  Overrides:
    paint in class ComponentUI

### paintHorizontalPartOfLeg

    protected void paintHorizontalPartOfLeg(java.awt.Graphics g,
                                            java.awt.Rectangle clipBounds,
                                            java.awt.Insets insets,
                                            java.awt.Rectangle bounds,
                                            TreePath path,
                                            int row,
                                            boolean isExpanded,
                                            boolean hasBeenExpanded,
                                            boolean isLeaf)

  Paints the horizontal part of the leg. The reciever should NOT modify `clipBounds`, or `insets`.

  NOTE: `parentRow` can be -1 if the root is not visible.

### paintVerticalPartOfLeg

    protected void paintVerticalPartOfLeg(java.awt.Graphics g,
                                          java.awt.Rectangle clipBounds,
                                          java.awt.Insets insets,
                                          TreePath path)

  Paints the vertical part of the leg. The reciever should NOT modify `clipBounds`, `insets`.

### paintExpandControl

    protected void paintExpandControl(java.awt.Graphics g,
                                      java.awt.Rectangle clipBounds,
                                      java.awt.Insets insets,
                                      java.awt.Rectangle bounds,
                                      TreePath path,
                                      int row,
                                      boolean isExpanded,
                                      boolean hasBeenExpanded,
                                      boolean isLeaf)

  Paints the expand (toggle) part of a row. The reciever should NOT modify `clipBounds`, or `insets`.

### paintRow

    protected void paintRow(java.awt.Graphics g,
                            java.awt.Rectangle clipBounds,
                            java.awt.Insets insets,
                            java.awt.Rectangle bounds,
                            TreePath path,
                            int row,
                            boolean isExpanded,
                            boolean hasBeenExpanded,
                            boolean isLeaf)

  Paints the renderer part of a row. The reciever should NOT modify `clipBounds`, or `insets`.

### shouldPaintExpandControl

    protected boolean shouldPaintExpandControl(TreePath path,
                                               int row,
                                               boolean isExpanded,
                                               boolean hasBeenExpanded,
                                               boolean isLeaf)

  Returns true if the expand (toggle) control should be drawn for the specified row.

### paintVerticalLine

    protected void paintVerticalLine(java.awt.Graphics g,
                                     JComponent c,
                                     int x,
                                     int top,
                                     int bottom)

  Paints a vertical line.

### paintHorizontalLine

    protected void paintHorizontalLine(java.awt.Graphics g,
                                       JComponent c,
                                       int y,
                                       int left,
                                       int right)

  Paints a horizontal line.

### getVerticalLegBuffer

    protected int getVerticalLegBuffer()

  The vertical element of legs between nodes starts at the bottom of the parent node by default. This method makes the leg start below that.

### getHorizontalLegBuffer

    protected int getHorizontalLegBuffer()

  The horizontal element of legs between nodes starts at the right of the left-hand side of the child node by default. This method makes the leg end before that.

### drawCentered

    protected void drawCentered(java.awt.Component c,
                                java.awt.Graphics graphics,
                                Icon icon,
                                int x,
                                int y)

### drawDashedHorizontalLine

    protected void drawDashedHorizontalLine(java.awt.Graphics g,
                                            int y,
                                            int x1,
                                            int x2)

### drawDashedVerticalLine

    protected void drawDashedVerticalLine(java.awt.Graphics g,
                                          int x,
                                          int y1,
                                          int y2)

### updateLayoutCacheExpandedNodes

    protected void updateLayoutCacheExpandedNodes()

  Makes all the nodes that are expanded in JTree expanded in LayoutCache. This invokes updateExpandedDescendants with the root path.

### updateExpandedDescendants

    protected void updateExpandedDescendants(TreePath path)

  Updates the expanded state of all the descendants of `path` by getting the expanded descendants from the tree and forwarding to the tree state.

### getLastChildPath

    protected TreePath getLastChildPath(TreePath parent)

  Returns a path to the last child of `parent`.

### updateDepthOffset

    protected void updateDepthOffset()

  Updates how much each depth should be offset by.

### updateCellEditor

    protected void updateCellEditor()

  Updates the cellEditor based on the editability of the JTree that we're contained in. If the tree is editable but doesn't have a cellEditor, a basic one will be used.

### updateRenderer

    protected void updateRenderer()

  Messaged from the tree we're in when the renderer has changed.

### configureLayoutCache

    protected void configureLayoutCache()

  Resets the TreeState instance based on the tree we're providing the look and feel for.

### updateSize

    protected void updateSize()

  Marks the cached size as being invalid, and messages the tree with `treeDidChange`.

### updateCachedPreferredSize

    protected void updateCachedPreferredSize()

  Updates the `preferredSize` instance variable, which is returned from `getPreferredSize()`.

  The size is determined from the current AbstractLayoutCache.

### pathWasExpanded

    protected void pathWasExpanded(TreePath path)

  Messaged from the VisibleTreeNode after it has been expanded.

### pathWasCollapsed

    protected void pathWasCollapsed(TreePath path)

  Messaged from the VisibleTreeNode after it has collapsed.

### ensureRowsAreVisible

    protected void ensureRowsAreVisible(int beginRow,
                                        int endRow)

  Ensures that the rows identified by beginRow through endRow are visible.

### setPreferredMinSize

    public void setPreferredMinSize(java.awt.Dimension newSize)

  Sets the preferred minimum size.

### getPreferredMinSize

    public java.awt.Dimension getPreferredMinSize()

  Returns the minimum preferred size.

### getPreferredSize

    public java.awt.Dimension getPreferredSize(JComponent c)

  Returns the preferred size to properly display the tree, this is a cover method for getPreferredSize(c, false).
  Overrides:
    getPreferredSize in class ComponentUI

### getPreferredSize

    public java.awt.Dimension getPreferredSize(JComponent c,
                                               boolean checkConsistancy)

  Returns the preferred size to represent the tree in c. If checkConsistancy is true checkConsistancy is messaged first.

### getMinimumSize

    public java.awt.Dimension getMinimumSize(JComponent c)

  Returns the minimum size for this component. Which will be the min preferred size or 0, 0.
  Overrides:
    getMinimumSize in class ComponentUI

### getMaximumSize

    public java.awt.Dimension getMaximumSize(JComponent c)

  Returns the maximum size for this component, which will be the preferred size if the instance is currently in a JTree, or 0, 0.
  Overrides:
    getMaximumSize in class ComponentUI

### completeEditing

    protected void completeEditing()

  Messages to stop the editing session. If the UI the receiver is providing the look and feel for returns true from `getInvokesStopCellEditing`, stopCellEditing will invoked on the current editor. Then completeEditing will be messaged with false, true, false to cancel any lingering editing.

### completeEditing

    protected void completeEditing(boolean messageStop,
                                   boolean messageCancel,
                                   boolean messageTree)

  Stops the editing session. If messageStop is true the editor is messaged with stopEditing, if messageCancel is true the editor is messaged with cancelEditing. If messageTree is true the treeModel is messaged with valueForPathChanged.

### startEditing

    protected boolean startEditing(TreePath path,
                                   java.awt.event.MouseEvent event)

  Will start editing for node if there is a cellEditor and shouldSelectCell returns true.

  This assumes that path is valid and visible.

### checkForClickInExpandControl

    protected void checkForClickInExpandControl(TreePath path,
                                                int mouseX,
                                                int mouseY)

  If the `mouseX` and `mouseY` are in the expand/collapse region of the `row`, this will toggle the row.

### isLocationInExpandControl

    protected boolean isLocationInExpandControl(TreePath path,
                                                int mouseX,
                                                int mouseY)

  Returns true if `mouseX` and `mouseY` fall in the area of row that is used to expand/collapse the node and the node at `row` does not represent a leaf.

### handleExpandControlClick

    protected void handleExpandControlClick(TreePath path,
                                            int mouseX,
                                            int mouseY)

  Messaged when the user clicks the particular row, this invokes toggleExpandState.

### toggleExpandState

    protected void toggleExpandState(TreePath path)

  Expands path if it is not expanded, or collapses row if it is expanded. If expanding a path and JTree scrolls on expand, ensureRowsAreVisible is invoked to scroll as many of the children to visible as possible (tries to scroll to last visible descendant of path).

### isToggleSelectionEvent

    protected boolean isToggleSelectionEvent(java.awt.event.MouseEvent event)

  Returning true signifies a mouse event on the node should toggle the selection of only the row under mouse.

### isMultiSelectEvent

    protected boolean isMultiSelectEvent(java.awt.event.MouseEvent event)

  Returning true signifies a mouse event on the node should select from the anchor point.

### isToggleEvent

    protected boolean isToggleEvent(java.awt.event.MouseEvent event)

  Returning true indicates the row under the mouse should be toggled based on the event. This is invoked after checkForClickInExpandControl, implying the location is not in the expand (toggle) control

### selectPathForEvent

    protected void selectPathForEvent(TreePath path,
                                      java.awt.event.MouseEvent event)

  Messaged to update the selection based on a MouseEvent over a particular row. If the event is a toggle selection event, the row is either selected, or deselected. If the event identifies a multi selection event, the selection is updated from the anchor point. Otherwise the row is selected, and if the event specified a toggle event the row is expanded/collapsed.

### isLeaf

    protected boolean isLeaf(int row)

  Returns:
    true if the node at `row` is a leaf.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.