public interface TreeNode<E>
setData(E)
) stored in the node.
It is designed to be used with DefaultTreeModel
.Modifier and Type | Method and Description |
---|---|
void |
add(TreeNode<E> child)
Adds a child to this node at the end.
|
java.lang.Object |
clone()
Clones the tree node.
|
TreeNode<E> |
getChildAt(int childIndex)
Returns the child
TreeNode at index
childIndex . |
int |
getChildCount()
Returns the number of children
TreeNode s this node
contains. |
java.util.List<TreeNode<E>> |
getChildren()
Return children of the receiver
|
E |
getData()
Returns the application-specific data of this node.
|
int |
getIndex(TreeNode<E> node)
Returns the index of
node in this node's children. |
DefaultTreeModel<E> |
getModel()
Returns the tree model it belongs to.
|
TreeNode<E> |
getParent()
Returns the parent
TreeNode of this node. |
void |
insert(TreeNode<E> child,
int index)
Adds child to this node at the given index.
|
boolean |
isLeaf()
Returns true if this node is a leaf.
|
void |
remove(int index)
Removes the child at index from this node.
|
void |
remove(TreeNode<E> child)
Removes the child from this node.
|
void |
setData(E data)
Sets the application-specific data associated with this node.
|
void |
setModel(DefaultTreeModel<E> model)
Sets the tree model it belongs to.
|
DefaultTreeModel<E> getModel()
void setModel(DefaultTreeModel<E> model)
This method is invoked automatically if DefaultTreeModel
,
so you don't have to invoke it.
java.lang.IllegalArgumentException
- if the model is null.java.lang.IllegalStateException
- if the node is not a root.E getData()
void setData(E data)
java.util.List<TreeNode<E>> getChildren()
int getChildCount()
TreeNode
s this node
contains.int getIndex(TreeNode<E> node)
node
in this node's children.
If this node does not contain node
, -1 will be
returned.boolean isLeaf()
void insert(TreeNode<E> child, int index)
java.lang.UnsupportedOperationException
- if the tree structure is not mutable,
or this node does not allow childrenjava.lang.IndexOutOfBoundsException
- if index
is out of boundsjava.lang.IllegalArgumentException
- if child
is an ancestor of this nodejava.lang.NullPointerException
- if child
is nullvoid add(TreeNode<E> child)
java.lang.UnsupportedOperationException
- if the tree structure is not mutable,
or this node does not allow childrenjava.lang.IllegalArgumentException
- if child
is an ancestor of this nodejava.lang.NullPointerException
- if child
is nullvoid remove(int index)
java.lang.UnsupportedOperationException
- if the tree structure is not mutable,
or this node does not allow childrenjava.lang.IndexOutOfBoundsException
- if index
is out of boundsvoid remove(TreeNode<E> child)
java.lang.UnsupportedOperationException
- if the tree structure is not mutable
or this node does not allow childrenjava.lang.IllegalArgumentException
- if child
is not a child of this nodejava.lang.Object clone()
Notes:
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.