public class DefaultTreeModel extends java.lang.Object implements TreeModel
| Constructor and Description |
|---|
DefaultTreeModel() |
DefaultTreeModel(TreeNode root) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
fireTreeNodesChanged(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
Notify all listeners of a node change.
|
protected void |
fireTreeNodesInserted(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
Notify all listeners of structure change.
|
protected void |
fireTreeNodesRemoved(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
Notify all listeners of structure change.
|
protected void |
fireTreeStructureChanged(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
Notify all listeners of structure change.
|
protected void |
fireTreeStructureChanged(java.lang.Object source,
TreePath path)
Notify all listeners of structure change.
|
java.lang.Object |
getChild(java.lang.Object parent,
int index)
Return the child of
parent at index index
in the parent's child array. |
int |
getChildCount(java.lang.Object parent)
Answer the number of children of
parent. |
int |
getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
Return the index of child in parent.
|
TreeNode[] |
getPathToRoot(TreeNode node)
Collect all parent nodes up to the root node.
|
protected TreeNode[] |
getPathToRoot(TreeNode node,
int depth)
Recursivly collect parent nodes up the the root node.
|
java.lang.Object |
getRoot()
Return the root of the tree.
|
java.util.Collection |
getTreeModelListeners()
Answer the mutable collection of tree model listeners.
|
boolean |
isLeaf(java.lang.Object node)
Answer
true if node is a leaf. |
void |
nodeChanged(TreeNode node)
Invoke this method after you've changed how node is to be
represented in the tree.
|
void |
nodesChanged(TreeNode node,
int[] childIndices)
Invoke this method after you've changed how the children identified by
childIndicies are to be represented in the tree.
|
void |
nodeStructureChanged(TreeNode node)
Invoke this method if you've totally changed the children of
node and its childrens children...
|
void |
nodesWereInserted(TreeNode node,
int[] childIndices)
Invoke this method after you've inserted some TreeNodes into
node.
|
void |
nodesWereRemoved(TreeNode node,
int[] childIndices,
java.lang.Object[] removedChildren)
Invoke this method after you've removed some TreeNodes from
node.
|
void |
valueForPathChanged(TreePath path,
java.lang.Object newValue)
Called when the value for the item identified
by
path has changed to newValue. |
public DefaultTreeModel()
public DefaultTreeModel(TreeNode root)
public java.lang.Object getRoot()
TreeModelpublic java.lang.Object getChild(java.lang.Object parent,
int index)
TreeModelparent at index index
in the parent's child array.public int getChildCount(java.lang.Object parent)
TreeModelparent.getChildCount in interface TreeModelparent - a node in the treeparentpublic boolean isLeaf(java.lang.Object node)
TreeModeltrue if node is a leaf.public void valueForPathChanged(TreePath path, java.lang.Object newValue)
TreeModelpath has changed to newValue.
If newValue signifies a truly new value
the model should post a treeNodesChanged event.valueForPathChanged in interface TreeModelpath - path to the node that has been alterednewValue - the new value from the TreeCellEditorpublic int getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
TreeModelgetIndexOfChild in interface TreeModelparent - a node in the treechild - the node we are interested inchild or parent are nullpublic java.util.Collection getTreeModelListeners()
TreeModelgetTreeModelListeners in interface TreeModelpublic void nodeChanged(TreeNode node)
public void nodesChanged(TreeNode node, int[] childIndices)
public void nodeStructureChanged(TreeNode node)
public void nodesWereInserted(TreeNode node, int[] childIndices)
public void nodesWereRemoved(TreeNode node, int[] childIndices, java.lang.Object[] removedChildren)
public TreeNode[] getPathToRoot(TreeNode node)
node - the TreeNode to get the path forprotected TreeNode[] getPathToRoot(TreeNode node, int depth)
node - the TreeNode to get the path fordepth - number of steps already taken towards the root (on recursive calls)protected void fireTreeNodesChanged(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
source - the node being changedpath - the path to the root nodechildIndices - the indices of the changed elementschildren - the changed elementsprotected void fireTreeNodesInserted(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
source - the node where new elements are being insertedpath - the path to the root nodechildIndices - the indices of the new elementschildren - the new elementsprotected void fireTreeNodesRemoved(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
source - the node where elements are being removedpath - the path to the root nodechildIndices - the indices of the removed elementschildren - the removed elementsprotected void fireTreeStructureChanged(java.lang.Object source,
java.lang.Object[] path,
int[] childIndices,
java.lang.Object[] children)
source - the node where the tree model has changedpath - the path to the root nodechildIndices - the indices of the affected elementschildren - the affected elementsprotected void fireTreeStructureChanged(java.lang.Object source,
TreePath path)
source - the node where the tree model has changedpath - the path to the root node