com.alee.laf.tree
Class WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTree
                  extended by com.alee.laf.tree.WebTree<E>
Type Parameters:
E - tree nodes type
All Implemented Interfaces:
FontMethods<WebTree<E>>, SwingMethods, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable
Direct Known Subclasses:
DictionariesTree, WebAsyncTree, WebCheckBoxTree

public class WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>
extends javax.swing.JTree
implements FontMethods<WebTree<E>>

This JTree extension class provides a direct access to WebTreeUI methods. There is also a set of additional methods to simplify some operations with tree.

This component should never be used with a non-Web UIs as it might cause an unexpected behavior. You could still use that component even if WebLaF is not your application L&F as this component will use Web-UI in any case.

Author:
Mikle Garin
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTree
javax.swing.JTree.AccessibleJTree, javax.swing.JTree.DropLocation, javax.swing.JTree.DynamicUtilTreeNode, javax.swing.JTree.EmptySelectionModel, javax.swing.JTree.TreeModelHandler, javax.swing.JTree.TreeSelectionRedirector
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.util.List<javax.swing.event.CellEditorListener> cellEditorListeners
          Tree cell editor listeners.
static int CONTIGUOUS_TREE_SELECTION
          Contiguous selection mode.
static int DISCONTIGUOUS_TREE_SELECTION
          Discontiguous selection mode.
protected  javax.swing.event.TreeSelectionListener scrollToSelectionListener
          Listener that forces tree to scroll view to selection.
static int SINGLE_TREE_SELECTION
          Single selection mode.
 
Fields inherited from class javax.swing.JTree
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, editable, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, invokesStopCellEditing, LARGE_MODEL_PROPERTY, largeModel, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, rootVisible, ROW_HEIGHT_PROPERTY, rowHeight, SCROLLS_ON_EXPAND_PROPERTY, scrollsOnExpand, SELECTION_MODEL_PROPERTY, selectionModel, selectionRedirector, SHOWS_ROOT_HANDLES_PROPERTY, showsRootHandles, TOGGLE_CLICK_COUNT_PROPERTY, toggleClickCount, TREE_MODEL_PROPERTY, treeModel, treeModelListener, VISIBLE_ROW_COUNT_PROPERTY, visibleRowCount
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
WebTree()
          Constructs tree with default sample model.
WebTree(E root)
          Constructs tree with model based on specified root node.
WebTree(E root, boolean asksAllowsChildren)
          Constructs tree with model based on specified root node and which decides whether a node is a leaf node in the specified manner.
WebTree(java.util.Hashtable<?,?> value)
          Constructs tree with model based on specified values.
WebTree(java.lang.Object[] value)
          Constructs tree with model based on specified values.
WebTree(javax.swing.tree.TreeModel newModel)
          Constructs tree with specified model.
WebTree(java.util.Vector<?> value)
          Constructs tree with model based on specified values.
 
Method Summary
 void addCellEditorListener(javax.swing.event.CellEditorListener listener)
          Adds tree cell editor listener.
 WebTree<E> changeFontSize(int change)
          Changes font size of the specified component.
protected static javax.swing.tree.TreeModel createTreeModel(java.lang.Object value)
          Returns a TreeModel wrapping the specified object.
 void expandAll()
          Expands all tree rows in a single call.
 void expandNode(E node)
          Expands the specified node.
 void expandRoot()
          Expands the root path, assuming the current TreeModel has been set.
 java.util.List<E> getAllNodes()
          Returns list of all nodes added into the tree.
 E getClosestNodeForLocation(int x, int y)
          Returns closest tree node for the specified location.
 E getClosestNodeForLocation(java.awt.Point location)
          Returns closest tree node for the specified location.
 javax.swing.tree.TreePath getClosestPathForLocation(java.awt.Point location)
          Returns the path to the node that is closest to the specified location.
static javax.swing.tree.TreeModel getDefaultTreeModel()
          Creates and returns a sample TreeModel.
 int getDropCellShadeWidth()
          Returns drop cell highlight shade width.
 E getFirstVisibleLeafNode()
          Returns first visible leaf node from the top of the tree.
 java.lang.String getFontName()
          Returns component font name.
 int getFontSize()
          Returns component font size.
 java.awt.Color getLinesColor()
          Returns tree structure lines color.
 java.awt.Rectangle getNodeBounds(E node)
          Returns node bounds.
 java.awt.Rectangle getNodeBounds(java.util.List<E> nodes)
          Returns nodes combined bounds.
 E getNodeForLocation(int x, int y)
          Returns tree node for the specified location.
 E getNodeForLocation(java.awt.Point location)
          Returns tree node for the specified location.
 E getNodeForPath(javax.swing.tree.TreePath path)
          Returns tree node for specified path.
 E getNodeForRow(int row)
          Returns tree node for the specified row.
 javax.swing.tree.TreePath getPathForLocation(java.awt.Point location)
          Returns the path for the node at the specified location.
 javax.swing.tree.TreePath getPathForNode(E node)
          Returns tree path for specified node.
 E getRootNode()
          Returns tree root node.
 E getSelectedNode()
          Returns selected node.
 java.util.List<E> getSelectedNodes()
          Returns selected nodes.
 int getSelectionRound()
          Returns tree selection rounding.
 int getSelectionShadeWidth()
          Returns tree selection shade width.
 TreeSelectionStyle getSelectionStyle()
          Returns tree selection style.
 java.awt.Color getSelectorBorderColor()
          Returns selector border color.
 java.awt.Color getSelectorColor()
          Returns selector color.
 int getSelectorRound()
          Returns selector rounding.
 java.awt.BasicStroke getSelectorStroke()
          Returns selector border stroke.
 TreeState getTreeState()
          Returns tree expansion and selection states.
 TreeState getTreeState(boolean saveSelection)
          Returns tree expansion and selection states.
 WebTreeUI getWebUI()
          Returns Web-UI applied to this class.
protected  void init()
          Initializes additional tree settings.
 boolean isAutoExpandSelectedNode()
          Returns whether tree should expand nodes on selection or not.
 boolean isBoldFont()
          Returns whether component font is bold or not.
 boolean isExpanded(E node)
          Returns whether node is expanded or not.
 boolean isHighlightRolloverNode()
          Returns whether tree should highlight rollover node or not.
 boolean isItalicFont()
          Returns whether component font is italic or not.
 boolean isPaintLines()
          Returns whether tree should paint structure lines or not.
 boolean isPlainFont()
          Returns whether component font is plain or not.
 boolean isRolloverSelectionEnabled()
          Returns whether rollover selection is enabled for this list or not.
 boolean isScrollToSelection()
          Returns whether tree automatically scrolls to selection or not.
 boolean isSelected(E node)
          Returns whether specified node is selected or not.
 boolean isSelectorEnabled()
          Returns whether selector is enabled or not.
 void removeCellEditorListener(javax.swing.event.CellEditorListener listener)
          Removes tree cell editor listener.
 void repaint(E node)
          Repaints specified node.
 void repaint(int row)
          Repaints specified tree row.
 void repaint(int from, int to)
          Repaints all tree rows in specified range.
 void repaint(java.util.List<E> nodes)
          Repaints specified node.
 void scrollToNode(E node)
          Scrolls tree view to specified node.
 void scrollToSelection()
          Scrolls tree view to selected nodes.
 void scrollToStart()
          Scrolls tree view to the beginning of the tree.
 void selectFirstVisibleLeafNode()
          Selects first visible leaf node from the top of the tree.
 void selectNextRow()
          Selects row next to currently selected.
 void selectNextRow(boolean cycle)
          Selects row next to currently selected.
 void selectNodeUnderPoint(int x, int y)
          Selects node under the specified point.
 void selectNodeUnderPoint(java.awt.Point point)
          Selects node under the specified point.
 void selectPreviousRow()
          Selects row next to currently selected.
 void selectPreviousRow(boolean cycle)
          Selects row previous to currently selected.
 void setAutoExpandSelectedNode(boolean autoExpandSelectedNode)
          Sets whether tree should expand nodes on selection or not.
 WebTree<E> setBoldFont()
          Sets bold font for the component.
 WebTree<E> setBoldFont(boolean apply)
          Sets bold font for the component.
 void setCellEditor(javax.swing.tree.TreeCellEditor cellEditor)
          
 void setDropCellShadeWidth(int dropCellShadeWidth)
          Sets drop cell highlight shade width.
 WebTree<E> setFontName(java.lang.String fontName)
          Sets component font name.
 WebTree<E> setFontSize(int fontSize)
          Sets component font size.
 WebTree<E> setFontSizeAndStyle(int fontSize, boolean bold, boolean italic)
          Sets font size and style for the specified component.
 WebTree<E> setFontSizeAndStyle(int fontSize, int style)
          Sets font size and style for the specified component.
 WebTree<E> setFontStyle(boolean bold, boolean italic)
          Sets component font style.
 WebTree<E> setFontStyle(int style)
          Sets component font style.
 void setHighlightRolloverNode(boolean highlight)
          Sets whether tree should highlight rollover node or not.
 WebTree<E> setItalicFont()
          Sets italic or plain font for the component.
 WebTree<E> setItalicFont(boolean apply)
          Sets italic or plain font for the component.
 void setLinesColor(java.awt.Color color)
          Sets tree structure lines color.
 void setMultiplySelectionAllowed(boolean allowed)
          Sets whether multiply nodes selection allowed or not.
 void setPaintLines(boolean paint)
          Sets whether tree should paint structure lines or not.
 WebTree<E> setPlainFont()
          Sets plain font for the component.
 WebTree<E> setPlainFont(boolean apply)
          Sets plain font for the component.
 void setRolloverSelectionEnabled(boolean enabled)
          Sets whether rollover selection is enabled for this list or not.
 void setScrollToSelection(boolean scroll)
          Sets whether tree should automatically scroll to selection or not.
 void setSelectedNode(E node)
          Sets selected nodes.
 void setSelectedNodes(E[] nodes)
          Sets selected nodes.
 void setSelectedNodes(java.util.List<E> nodes)
          Sets selected nodes.
 void setSelectionMode(int mode)
          Sets tree selection mode.
 void setSelectionRound(int round)
          Sets tree selection rounding.
 void setSelectionShadeWidth(int shadeWidth)
          Sets tree selection shade width.
 void setSelectionStyle(TreeSelectionStyle style)
          Sets tree selection style.
 void setSelectorBorderColor(java.awt.Color color)
          Sets selector border color.
 void setSelectorColor(java.awt.Color color)
          Sets selector color.
 void setSelectorEnabled(boolean enabled)
          Sets whether selector is enabled or not.
 void setSelectorRound(int round)
          Sets selector rounding.
 void setSelectorStroke(java.awt.BasicStroke stroke)
          Sets selector border stroke.
 void setTreeState(TreeState treeState)
          Restores tree expansion and selection states.
 void setTreeState(TreeState treeState, boolean restoreSelection)
          Restores tree expansion and selection states.
 void startEditingNode(E node)
          Starts editing the specified node.
 void startEditingSelectedNode()
          Starts editing selected tree node.
 void updateAllVisibleNodes()
          Updates all visible nodes.
 void updateUI()
          Installs a Web-UI into this component.
 
Methods inherited from class javax.swing.JTree
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, clearToggledPaths, collapsePath, collapseRow, convertValueToText, createTreeModelListener, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, fireValueChanged, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDescendantToggledPaths, getDragEnabled, getDropLocation, getDropMode, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, getNextMatch, getPathBetweenRows, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getToolTipText, getTreeExpansionListeners, getTreeSelectionListeners, getTreeWillExpandListeners, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isEditing, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isSelectionEmpty, isVisible, makeVisible, paramString, removeDescendantSelectedPaths, removeDescendantToggledPaths, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellRenderer, setDragEnabled, setDropMode, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setModel, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, startEditingAtPath, stopEditing, treeDidChange
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SINGLE_TREE_SELECTION

public static final int SINGLE_TREE_SELECTION
Single selection mode. Only one node can be selected.

See Also:
Constant Field Values

CONTIGUOUS_TREE_SELECTION

public static final int CONTIGUOUS_TREE_SELECTION
Contiguous selection mode. Any amount of nodes can be selected in a row.

See Also:
Constant Field Values

DISCONTIGUOUS_TREE_SELECTION

public static final int DISCONTIGUOUS_TREE_SELECTION
Discontiguous selection mode. Any amount of nodes can be selected anywhere.

See Also:
Constant Field Values

cellEditorListeners

protected java.util.List<javax.swing.event.CellEditorListener> cellEditorListeners
Tree cell editor listeners. These listeners act separately from the cell editor and will be moved to new tree cell editor automatically on set.


scrollToSelectionListener

protected javax.swing.event.TreeSelectionListener scrollToSelectionListener
Listener that forces tree to scroll view to selection. It is disabled by default and null in that case.

Constructor Detail

WebTree

public WebTree()
Constructs tree with default sample model.


WebTree

public WebTree(java.lang.Object[] value)
Constructs tree with model based on specified values.

Parameters:
value - tree data

WebTree

public WebTree(java.util.Vector<?> value)
Constructs tree with model based on specified values.

Parameters:
value - tree data

WebTree

public WebTree(java.util.Hashtable<?,?> value)
Constructs tree with model based on specified values.

Parameters:
value - tree data

WebTree

public WebTree(E root)
Constructs tree with model based on specified root node.

Parameters:
root - tree root node

WebTree

public WebTree(E root,
               boolean asksAllowsChildren)
Constructs tree with model based on specified root node and which decides whether a node is a leaf node in the specified manner.

Parameters:
root - tree root node
asksAllowsChildren - false if any node can have children, true if each node is asked to see if it can have children

WebTree

public WebTree(javax.swing.tree.TreeModel newModel)
Constructs tree with specified model.

Parameters:
newModel - tree model
Method Detail

init

protected void init()
Initializes additional tree settings.


setCellEditor

public void setCellEditor(javax.swing.tree.TreeCellEditor cellEditor)

Overrides:
setCellEditor in class javax.swing.JTree

addCellEditorListener

public void addCellEditorListener(javax.swing.event.CellEditorListener listener)
Adds tree cell editor listener. These listeners act separately from the cell editor and will be moved to new tree cell editor automatically on set.

Parameters:
listener - cell editor listener to add

removeCellEditorListener

public void removeCellEditorListener(javax.swing.event.CellEditorListener listener)
Removes tree cell editor listener.

Parameters:
listener - cell editor listener to remove

expandRoot

public void expandRoot()
Expands the root path, assuming the current TreeModel has been set.


expandAll

public void expandAll()
Expands all tree rows in a single call. It is not recommended to expand large trees this way since that might cause huge interface lags.


expandNode

public void expandNode(E node)
Expands the specified node.

Parameters:
node - node to expand

isExpanded

public boolean isExpanded(E node)
Returns whether node is expanded or not.

Parameters:
node - node to check
Returns:
true if node is expanded, false otherwise

getNodeBounds

public java.awt.Rectangle getNodeBounds(E node)
Returns node bounds.

Parameters:
node - node to process
Returns:
node bounds

getNodeBounds

public java.awt.Rectangle getNodeBounds(java.util.List<E> nodes)
Returns nodes combined bounds.

Parameters:
nodes - nodes to process
Returns:
nodes combined bounds

getNodeForRow

public E getNodeForRow(int row)
Returns tree node for the specified row.

Parameters:
row - row to process
Returns:
tree node for the specified row

getPathForNode

public javax.swing.tree.TreePath getPathForNode(E node)
Returns tree path for specified node.

Parameters:
node - node to process
Returns:
tree path

getNodeForPath

public E getNodeForPath(javax.swing.tree.TreePath path)
Returns tree node for specified path.

Parameters:
path - path to process
Returns:
tree node for specified path

getNodeForLocation

public E getNodeForLocation(java.awt.Point location)
Returns tree node for the specified location.

Parameters:
location - location to process
Returns:
tree node for the specified location

getNodeForLocation

public E getNodeForLocation(int x,
                            int y)
Returns tree node for the specified location.

Parameters:
x - location X coordinate
y - location Y coordinate
Returns:
tree node for the specified location

getPathForLocation

public javax.swing.tree.TreePath getPathForLocation(java.awt.Point location)
Returns the path for the node at the specified location.

Parameters:
location - location to process
Returns:
the TreePath for the node at that location

getClosestNodeForLocation

public E getClosestNodeForLocation(java.awt.Point location)
Returns closest tree node for the specified location.

Parameters:
location - location to process
Returns:
tree node for the specified location

getClosestNodeForLocation

public E getClosestNodeForLocation(int x,
                                   int y)
Returns closest tree node for the specified location.

Parameters:
x - location X coordinate
y - location Y coordinate
Returns:
tree node for the specified location

getClosestPathForLocation

public javax.swing.tree.TreePath getClosestPathForLocation(java.awt.Point location)
Returns the path to the node that is closest to the specified location.

Parameters:
location - location to process
Returns:
the TreePath for the node closest to that location, null if nothing is viewable or there is no model

isSelected

public boolean isSelected(E node)
Returns whether specified node is selected or not.

Parameters:
node - node to check
Returns:
true if specified node is selected, false otherwise

getSelectedNode

public E getSelectedNode()
Returns selected node.

Returns:
selected node

getSelectedNodes

public java.util.List<E> getSelectedNodes()
Returns selected nodes.

Returns:
selected nodes

selectNodeUnderPoint

public void selectNodeUnderPoint(java.awt.Point point)
Selects node under the specified point.

Parameters:
point - point to look for node

selectNodeUnderPoint

public void selectNodeUnderPoint(int x,
                                 int y)
Selects node under the specified point.

Parameters:
x - point X coordinate
y - point Y coordinate

setSelectedNode

public void setSelectedNode(E node)
Sets selected nodes.


setSelectedNodes

public void setSelectedNodes(java.util.List<E> nodes)
Sets selected nodes.


setSelectedNodes

public void setSelectedNodes(E[] nodes)
Sets selected nodes.


getFirstVisibleLeafNode

public E getFirstVisibleLeafNode()
Returns first visible leaf node from the top of the tree. This doesn't include nodes under collapsed paths but does include nodes which are not in visible rect.

Returns:
first visible leaf node from the top of the tree

selectFirstVisibleLeafNode

public void selectFirstVisibleLeafNode()
Selects first visible leaf node from the top of the tree.


selectNextRow

public void selectNextRow()
Selects row next to currently selected. First row will be selected if none or last row was selected.


selectNextRow

public void selectNextRow(boolean cycle)
Selects row next to currently selected. First row will be selected if none was selected. First row will be selected if last row was selected and cycling is allowed.


selectPreviousRow

public void selectPreviousRow()
Selects row next to currently selected. Last row will be selected if none or first row was selected.


selectPreviousRow

public void selectPreviousRow(boolean cycle)
Selects row previous to currently selected. Last row will be selected if none or last was selected. Last row will be selected if first row was selected and cycling is allowed.


getRootNode

public E getRootNode()
Returns tree root node.

Returns:
tree root node

getAllNodes

public java.util.List<E> getAllNodes()
Returns list of all nodes added into the tree.

Returns:
list of all nodes added into the tree

setSelectionMode

public void setSelectionMode(int mode)
Sets tree selection mode.

Parameters:
mode - tree selection mode

setMultiplySelectionAllowed

public void setMultiplySelectionAllowed(boolean allowed)
Sets whether multiply nodes selection allowed or not. This call simply changes selection mode according to provided value.

Parameters:
allowed - whether multiply nodes selection allowed or not

isScrollToSelection

public boolean isScrollToSelection()
Returns whether tree automatically scrolls to selection or not.

Returns:
true if tree automatically scrolls to selection, false otherwise

setScrollToSelection

public void setScrollToSelection(boolean scroll)
Sets whether tree should automatically scroll to selection or not.

Parameters:
scroll - whether tree should automatically scroll to selection or not

scrollToStart

public void scrollToStart()
Scrolls tree view to the beginning of the tree.


scrollToSelection

public void scrollToSelection()
Scrolls tree view to selected nodes.


scrollToNode

public void scrollToNode(E node)
Scrolls tree view to specified node.

Parameters:
node - node to scroll to

startEditingSelectedNode

public void startEditingSelectedNode()
Starts editing selected tree node.


startEditingNode

public void startEditingNode(E node)
Starts editing the specified node.

Parameters:
node - tree node to edit

updateAllVisibleNodes

public void updateAllVisibleNodes()
Updates all visible nodes. This might be used to update node sizes if renderer has changed.


getTreeState

public TreeState getTreeState()
Returns tree expansion and selection states. Tree nodes must be instances of UniqueNode class.

Returns:
tree expansion and selection states

getTreeState

public TreeState getTreeState(boolean saveSelection)
Returns tree expansion and selection states. Tree nodes must be instances of UniqueNode class.

Parameters:
saveSelection - whether to save selection states or not
Returns:
tree expansion and selection states

setTreeState

public void setTreeState(TreeState treeState)
Restores tree expansion and selection states. Tree nodes must be instances of UniqueNode class.

Parameters:
treeState - tree expansion and selection states

setTreeState

public void setTreeState(TreeState treeState,
                         boolean restoreSelection)
Restores tree expansion and selection states. Tree nodes must be instances of UniqueNode class.

Parameters:
treeState - tree expansion and selection states
restoreSelection - whether to restore selection states or not

isAutoExpandSelectedNode

public boolean isAutoExpandSelectedNode()
Returns whether tree should expand nodes on selection or not.

Returns:
true if tree should expand nodes on selection, false otherwise

setAutoExpandSelectedNode

public void setAutoExpandSelectedNode(boolean autoExpandSelectedNode)
Sets whether tree should expand nodes on selection or not.

Parameters:
autoExpandSelectedNode - whether tree should expand nodes on selection or not

isRolloverSelectionEnabled

public boolean isRolloverSelectionEnabled()
Returns whether rollover selection is enabled for this list or not.

Returns:
true if rollover selection is enabled for this list, false otherwise

setRolloverSelectionEnabled

public void setRolloverSelectionEnabled(boolean enabled)
Sets whether rollover selection is enabled for this list or not.

Parameters:
enabled - whether rollover selection is enabled for this list or not

isHighlightRolloverNode

public boolean isHighlightRolloverNode()
Returns whether tree should highlight rollover node or not.

Returns:
true if tree should highlight rollover, false otherwise

setHighlightRolloverNode

public void setHighlightRolloverNode(boolean highlight)
Sets whether tree should highlight rollover node or not.

Parameters:
highlight - whether tree should highlight rollover node or not

isPaintLines

public boolean isPaintLines()
Returns whether tree should paint structure lines or not.

Returns:
true if tree should paint structure lines, false otherwise

setPaintLines

public void setPaintLines(boolean paint)
Sets whether tree should paint structure lines or not.

Parameters:
paint - whether tree should paint structure lines or not

getLinesColor

public java.awt.Color getLinesColor()
Returns tree structure lines color.

Returns:
tree structure lines color

setLinesColor

public void setLinesColor(java.awt.Color color)
Sets tree structure lines color.

Parameters:
color - tree structure lines color

getSelectionStyle

public TreeSelectionStyle getSelectionStyle()
Returns tree selection style.

Returns:
tree selection style

setSelectionStyle

public void setSelectionStyle(TreeSelectionStyle style)
Sets tree selection style.

Parameters:
style - tree selection style

getSelectionRound

public int getSelectionRound()
Returns tree selection rounding.

Returns:
tree selection rounding

setSelectionRound

public void setSelectionRound(int round)
Sets tree selection rounding.

Parameters:
round - tree selection rounding

getSelectionShadeWidth

public int getSelectionShadeWidth()
Returns tree selection shade width.

Returns:
tree selection shade width

setSelectionShadeWidth

public void setSelectionShadeWidth(int shadeWidth)
Sets tree selection shade width.

Parameters:
shadeWidth - tree selection shade width

isSelectorEnabled

public boolean isSelectorEnabled()
Returns whether selector is enabled or not.

Returns:
true if selector is enabled, false otherwise

setSelectorEnabled

public void setSelectorEnabled(boolean enabled)
Sets whether selector is enabled or not.

Parameters:
enabled - whether selector is enabled or not

getSelectorColor

public java.awt.Color getSelectorColor()
Returns selector color.

Returns:
selector color

setSelectorColor

public void setSelectorColor(java.awt.Color color)
Sets selector color.

Parameters:
color - selector color

getSelectorBorderColor

public java.awt.Color getSelectorBorderColor()
Returns selector border color.

Returns:
selector border color

setSelectorBorderColor

public void setSelectorBorderColor(java.awt.Color color)
Sets selector border color.

Parameters:
color - selector border color

getSelectorRound

public int getSelectorRound()
Returns selector rounding.

Returns:
selector rounding

setSelectorRound

public void setSelectorRound(int round)
Sets selector rounding.

Parameters:
round - selector rounding

getSelectorStroke

public java.awt.BasicStroke getSelectorStroke()
Returns selector border stroke.

Returns:
selector border stroke

setSelectorStroke

public void setSelectorStroke(java.awt.BasicStroke stroke)
Sets selector border stroke.

Parameters:
stroke - selector border stroke

getDropCellShadeWidth

public int getDropCellShadeWidth()
Returns drop cell highlight shade width.

Returns:
drop cell highlight shade width

setDropCellShadeWidth

public void setDropCellShadeWidth(int dropCellShadeWidth)
Sets drop cell highlight shade width.

Parameters:
dropCellShadeWidth - new drop cell highlight shade width

getWebUI

public WebTreeUI getWebUI()
Returns Web-UI applied to this class.

Returns:
Web-UI applied to this class

updateUI

public void updateUI()
Installs a Web-UI into this component.

Overrides:
updateUI in class javax.swing.JTree

repaint

public void repaint(int row)
Repaints specified tree row.

Parameters:
row - row index

repaint

public void repaint(int from,
                    int to)
Repaints all tree rows in specified range.

Parameters:
from - first row index
to - last row index

repaint

public void repaint(E node)
Repaints specified node.

Parameters:
node - node to repaint

repaint

public void repaint(java.util.List<E> nodes)
Repaints specified node.

Parameters:
nodes - nodes to repaint

setPlainFont

public WebTree<E> setPlainFont()
Sets plain font for the component.

Specified by:
setPlainFont in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Returns:
modified component

setPlainFont

public WebTree<E> setPlainFont(boolean apply)
Sets plain font for the component.

Specified by:
setPlainFont in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Parameters:
apply - whether to apply font changes or not
Returns:
modified component

isPlainFont

public boolean isPlainFont()
Returns whether component font is plain or not.

Specified by:
isPlainFont in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Returns:
true if component font is plain, false otherwise

setBoldFont

public WebTree<E> setBoldFont()
Sets bold font for the component.

Specified by:
setBoldFont in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Returns:
modified component

setBoldFont

public WebTree<E> setBoldFont(boolean apply)
Sets bold font for the component.

Specified by:
setBoldFont in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Parameters:
apply - whether to apply font changes or not
Returns:
modified component

isBoldFont

public boolean isBoldFont()
Returns whether component font is bold or not.

Specified by:
isBoldFont in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Returns:
true if component font is bold, false otherwise

setItalicFont

public WebTree<E> setItalicFont()
Sets italic or plain font for the component.

Specified by:
setItalicFont in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Returns:
modified component

setItalicFont

public WebTree<E> setItalicFont(boolean apply)
Sets italic or plain font for the component.

Specified by:
setItalicFont in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Parameters:
apply - whether to apply font changes or not
Returns:
modified component

isItalicFont

public boolean isItalicFont()
Returns whether component font is italic or not.

Specified by:
isItalicFont in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Returns:
true if component font is italic, false otherwise

setFontStyle

public WebTree<E> setFontStyle(boolean bold,
                               boolean italic)
Sets component font style.

Specified by:
setFontStyle in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Parameters:
bold - whether should set bold font or not
italic - whether should set italic font or not
Returns:
modified component

setFontStyle

public WebTree<E> setFontStyle(int style)
Sets component font style.

Specified by:
setFontStyle in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Parameters:
style - new style
Returns:
modified component

setFontSize

public WebTree<E> setFontSize(int fontSize)
Sets component font size.

Specified by:
setFontSize in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Parameters:
fontSize - font size
Returns:
modified component

changeFontSize

public WebTree<E> changeFontSize(int change)
Changes font size of the specified component.

Specified by:
changeFontSize in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Parameters:
change - font size change amount
Returns:
modified component

getFontSize

public int getFontSize()
Returns component font size.

Specified by:
getFontSize in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Returns:
component font size

setFontSizeAndStyle

public WebTree<E> setFontSizeAndStyle(int fontSize,
                                      boolean bold,
                                      boolean italic)
Sets font size and style for the specified component.

Specified by:
setFontSizeAndStyle in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Parameters:
fontSize - new font size
bold - whether should set bold font or not
italic - whether should set italic font or not
Returns:
modified component

setFontSizeAndStyle

public WebTree<E> setFontSizeAndStyle(int fontSize,
                                      int style)
Sets font size and style for the specified component.

Specified by:
setFontSizeAndStyle in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Parameters:
fontSize - new font size
style - new style
Returns:
modified component

setFontName

public WebTree<E> setFontName(java.lang.String fontName)
Sets component font name.

Specified by:
setFontName in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Parameters:
fontName - new font name
Returns:
modified component

getFontName

public java.lang.String getFontName()
Returns component font name.

Specified by:
getFontName in interface FontMethods<WebTree<E extends javax.swing.tree.DefaultMutableTreeNode>>
Returns:
component font name

createTreeModel

protected static javax.swing.tree.TreeModel createTreeModel(java.lang.Object value)
Returns a TreeModel wrapping the specified object. If the object is an array of Object, Hashtable or Vector then a new root node is created with each of the incoming objects as children. Otherwise, a new root is created with the specified object as its value.

Parameters:
value - Object used as the foundation for the TreeModel
Returns:
a TreeModel wrapping the specified object

getDefaultTreeModel

public static javax.swing.tree.TreeModel getDefaultTreeModel()
Creates and returns a sample TreeModel. Used primarily for beanbuilders to show something interesting.

Returns:
the default TreeModel