Class CheckboxTree

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class CheckboxTree extends JTree
Author:
bigagli
See Also:
  • Constructor Details

    • CheckboxTree

      public CheckboxTree()
      For GUI builders. It returns a CheckboxTree with a default tree model to show something interesting. Creates a CheckboxTree with visible handles, a default CheckboxTreeCellRenderer and a default TreeCheckingModel.
    • CheckboxTree

      public CheckboxTree(TreeModel treemodel)
      Create a CheckboxTree with visible handles, a default CheckboxTreeCellRenderer and a default TreeCheckingModel. The tree is based on the specified tree model.
      Parameters:
      treemodel - the model of this tree
    • CheckboxTree

      public CheckboxTree(TreeNode root)
      Create a CheckboxTree with visible handles, a default CheckboxTreeCellRenderer and a default TreeCheckingModel. The tree root is the specified tree node.
      Parameters:
      root - the root of the tree
  • Method Details

    • addCheckingPath

      public void addCheckingPath(TreePath path)
      Add a path in the checking.
      Parameters:
      path - the path to add
    • addCheckingPaths

      public void addCheckingPaths(TreePath[] paths)
      Add paths in the checking.
    • addTreeCheckingListener

      public void addTreeCheckingListener(TreeCheckingListener tsl)
      Add a listener for TreeChecking events.
      Parameters:
      tsl - the TreeCheckingListener that will be notified when a node is checked
    • clearChecking

      public void clearChecking()
      Clear the checking set.
    • expandAll

      public void expandAll()
      Expand the tree completely.
    • getCheckingModel

      public TreeCheckingModel getCheckingModel()
      Return the TreeCheckingModel of this CheckboxTree. This method never returns null (although it may return the NullTreeCheckingModel singleton).
      Returns:
      the TreeCheckingModel of this CheckboxTree.
    • getCheckingPaths

      public TreePath[] getCheckingPaths()
      Return paths that are in the checking.
    • getCheckingRoots

      public TreePath[] getCheckingRoots()
      Returns:
      the paths that are in the checking set and are the (upper) roots of checked trees.
    • getGreyingPaths

      public TreePath[] getGreyingPaths()
      Returns:
      the paths that are in the greying.
    • isPathChecked

      public boolean isPathChecked(TreePath path)
      Return true if the item identified by the path is currently checked.
      Parameters:
      path - a TreePath identifying a node
      Returns:
      true if the node is checked
    • isSelectsByChecking

      public boolean isSelectsByChecking()
      Return whether checking a node causes it to be selected, too.
      Returns:
      the intended behavior of checking with respect to selection.
    • processMouseEvent

      protected void processMouseEvent(MouseEvent e)
      Overrides:
      processMouseEvent in class JComponent
    • removeCheckingPath

      public void removeCheckingPath(TreePath path)
      Remove a path from the checking.
    • removeCheckingPaths

      public void removeCheckingPaths(TreePath[] paths)
      Remove paths from the checking.
    • removeTreeCheckingListener

      public void removeTreeCheckingListener(TreeCheckingListener tcl)
      Remove a TreeChecking listener.
      Parameters:
      tcl - the TreeCheckingListener to remove
    • setCellRenderer

      public void setCellRenderer(TreeCellRenderer tcl)
      Set the CheckboxTreeCellRenderer that will be used to draw each cell.
      Overrides:
      setCellRenderer in class JTree
      Parameters:
      tcl - the TreeCellRenderer that is to render each cell
      Throws:
      IllegalArgumentException - if the argument is not a CheckboxTreeCellRenderer.
    • getCellRenderer

      public CheckboxTreeCellRenderer getCellRenderer()
      Co-variant method for retrieving the CheckboxTreeCellRenderer of this tree.
      Overrides:
      getCellRenderer in class JTree
    • setCheckingModel

      public void setCheckingModel(TreeCheckingModel newCheckingModel)
      Set the checking model of this CheckboxTree. If the parameter is null, the checking model is set to the NullTreeCheckingModel singleton.
      Parameters:
      newCheckingModel - the new TreeCheckingModel of this CheckboxTree.
    • setCheckingPath

      public void setCheckingPath(TreePath path)
      Set path in the checking.
    • setCheckingPaths

      public void setCheckingPaths(TreePath[] paths)
      Set paths that are in the checking.
    • setModel

      public void setModel(TreeModel newModel)
      Set the TreeModel and links it to the existing checkingModel.
      Overrides:
      setModel in class JTree
    • setSelectsByChecking

      public void setSelectsByChecking(boolean selectsByChecking)
      Specify whether checking a node causes it to be selected, too, or else the selection is not affected. The default behavior is the former.
      Parameters:
      selectsByChecking - the intended behavior of checking with respect to selection.
    • toString

      public String toString()
      Overrides:
      toString in class Component
      Returns:
      a string representation of the tree, including the checking, enabling and greying sets.