public class JMutableTreeNode
extends javax.swing.tree.DefaultMutableTreeNode
implements java.lang.Comparable
DefaultMutableTreeNode
that provides
support for the JTreeCell
data structure.Modifier and Type | Field and Description |
---|---|
protected JTreeCellData |
_treeCellData |
Constructor and Description |
---|
JMutableTreeNode()
Creates a tree node that has no parent and no children, but which
allows children.
|
JMutableTreeNode(JTreeCellData treeCellData)
Creates a tree node with no parent, no children, but which allows
children, and initializes it with the specified tree cell data.
|
JMutableTreeNode(JTreeCellData treeCellData,
boolean allowsChildren)
Creates a tree node with no parent, no children, initialized with the
specified tree cell data, and that allows children only if specified.
|
JMutableTreeNode(java.lang.String text)
Creates a tree node with no parent, no children, but which allows
children, and initializes it to contain a
JTreeCellData
object whose display string is the specified text . |
Modifier and Type | Method and Description |
---|---|
JMutableTreeNode |
add(JTreeCellData childNodeData)
Convenience method where a new child node is added by specifying
its data model.
|
void |
ascendingUpdateNodes() |
int |
compareTo(JMutableTreeNode otherNode)
Supports the
Comparable implementation so that
JMutableTreeNode s can be sorted using
Collections.sort() . |
int |
compareTo(java.lang.Object object) |
TriStateBoolean |
descendingUpdateNodes()
Beginning with the given
actionNode this method
recurses down the sub-tree and updates the checked status of
non-leaf checkboxes. |
JTreeCellData |
getModel()
Returns the data model being used by this
JMutableTreeNode . |
void |
selectDescendants(boolean b)
Starting with this tree node, select it and all of its
descendants according to the flag
b . |
void |
setModel(JTreeCellData treeCellData)
Sets the data model used by this
JMutableTreeNode . |
void |
sortChildren()
Sorts this node's children.
|
void |
sortChildren(int recursionLevel)
If the indicated recursion level is non-negative, this method
sorts the
JMutableTreeNode 's children and then
recurses the number of levels indicated to sort their children. |
void |
sortDescendents()
Sorts all levels of the subtree represented by this
JMutableTreeNode . |
JMutableTreeNode |
unselectSibling()
Method to unselect the current selected sibling
|
void |
updateNodes()
Method that re-synchronizes non-leaf checkboxes with the states
reflected in leaf checkboxes.
|
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
protected JTreeCellData _treeCellData
public JMutableTreeNode()
public JMutableTreeNode(java.lang.String text)
JTreeCellData
object whose display string is the specified text
.public JMutableTreeNode(JTreeCellData treeCellData)
public JMutableTreeNode(JTreeCellData treeCellData, boolean allowsChildren)
public int compareTo(java.lang.Object object)
compareTo
in interface java.lang.Comparable
public void selectDescendants(boolean b)
b
. If
b
is true
, then nodes are selected
(i.e. checked); otherwise, nodes are deselected (i.e.
unchecked).If the tree node is a radio button then it is enable or disabled because all the radio buttons within the group can't be selected. A typical usage of this method and related methods goes something like this:
someNode.selectDescendants( true ); someNode.updateNodes();This example enables all descendants, skipping disabled nodes (and thus skipping the sub-tree under a disabled node), and then makes another pass to make sure that non-leaf nodes have the proper check mark (checked, half-checked, unchecked).
public TriStateBoolean descendingUpdateNodes()
actionNode
this method
recurses down the sub-tree and updates the checked status of
non-leaf checkboxes. This method ignores the values held by non-leaf
checkboxes in the process of making them consistent with the states
set in leaf nodes. All checkboxes are updated whether they are
enabled or not.
It is best not to invoke this method directly but to use one of the
updateNodes()
methods instead. This is because nodes
closer to the root than actionNode
are not updated.
public void ascendingUpdateNodes()
public void updateNodes()
public JMutableTreeNode unselectSibling()
public int compareTo(JMutableTreeNode otherNode)
Comparable
implementation so that
JMutableTreeNode
s can be sorted using
Collections.sort()
.public JMutableTreeNode add(JTreeCellData childNodeData)
JMutableTreeNode
is
created and added.public JTreeCellData getModel()
JMutableTreeNode
.public void setModel(JTreeCellData treeCellData)
JMutableTreeNode
.public void sortChildren()
public void sortChildren(int recursionLevel)
JMutableTreeNode
's children and then
recurses the number of levels indicated to sort their children.public void sortDescendents()
JMutableTreeNode
.