org.openbp.swing.components.tree
Class DefaultTreeNode

java.lang.Object
  extended by org.openbp.swing.components.tree.DefaultTreeNode
All Implemented Interfaces:
javax.swing.tree.TreeNode

public class DefaultTreeNode
extends java.lang.Object
implements javax.swing.tree.TreeNode

General-purpose tree node that contains a parent tree node link and a list of child tree nodes.

Author:
Heiko Erhardt

Field Summary
protected  javax.swing.tree.TreeNode parent
          Parent tree node
 
Constructor Summary
DefaultTreeNode()
          Default constructor.
DefaultTreeNode(javax.swing.tree.TreeNode parent)
          Default constructor.
 
Method Summary
 void addChild(DefaultTreeNode child)
          Adds a child.
 java.util.Enumeration children()
          Returns an Enumeration off all children.
 void clearChilds()
          Clears the child list.
 boolean getAllowsChildren()
          Returns false.
 javax.swing.tree.TreeNode getChildAt(int index)
          Returns the child at the given position.
 int getChildCount()
          Returns the number of children in the entry.
 java.util.List getChildList()
          Gets the child list.
 int getIndex(javax.swing.tree.TreeNode treeNode)
          Returns the index of this child node.
 javax.swing.tree.TreeNode getParent()
          Gets the parent tree node.
 void insertChild(DefaultTreeNode child, int index)
          Inserts a child into the child list.
 boolean isLeaf()
          Determines if this is a leaf node.
 void removeChild(DefaultTreeNode child)
          Removes a child.
 void setChildList(java.util.List childList)
          Sets the child list.
 void setParent(javax.swing.tree.TreeNode parent)
          Sets the parent tree node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected javax.swing.tree.TreeNode parent
Parent tree node

Constructor Detail

DefaultTreeNode

public DefaultTreeNode()
Default constructor.


DefaultTreeNode

public DefaultTreeNode(javax.swing.tree.TreeNode parent)
Default constructor.

Parameters:
parent - Parent tree node
Method Detail

children

public java.util.Enumeration children()
Returns an Enumeration off all children.

Specified by:
children in interface javax.swing.tree.TreeNode
Returns:
an Enumeration value

getIndex

public int getIndex(javax.swing.tree.TreeNode treeNode)
Returns the index of this child node.

Specified by:
getIndex in interface javax.swing.tree.TreeNode
Parameters:
treeNode - The tree node
Returns:
0-based index or -1 if the node is not a child node of this one

isLeaf

public boolean isLeaf()
Determines if this is a leaf node.

Specified by:
isLeaf in interface javax.swing.tree.TreeNode
Returns:
true This node has no children.
false This node has at least one child.

getChildAt

public javax.swing.tree.TreeNode getChildAt(int index)
Returns the child at the given position.

Specified by:
getChildAt in interface javax.swing.tree.TreeNode
Parameters:
index - The 0-based position
Returns:
The node at this position or 0 if no such position exists

getChildCount

public int getChildCount()
Returns the number of children in the entry.

Specified by:
getChildCount in interface javax.swing.tree.TreeNode
Returns:
an int value

getAllowsChildren

public boolean getAllowsChildren()
Returns false.

Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode

getParent

public javax.swing.tree.TreeNode getParent()
Gets the parent tree node.

Specified by:
getParent in interface javax.swing.tree.TreeNode

setParent

public void setParent(javax.swing.tree.TreeNode parent)
Sets the parent tree node.


addChild

public void addChild(DefaultTreeNode child)
Adds a child.

Parameters:
child - The child to add

insertChild

public void insertChild(DefaultTreeNode child,
                        int index)
Inserts a child into the child list.

Parameters:
child - The child to add
index - 0-based index of the node the should preceede the new child

removeChild

public void removeChild(DefaultTreeNode child)
Removes a child.

Parameters:
child - The child to remove

clearChilds

public void clearChilds()
Clears the child list.


getChildList

public java.util.List getChildList()
Gets the child list.

Returns:
A list of TreeNode objects

setChildList

public void setChildList(java.util.List childList)
Sets the child list.

Parameters:
childList - A list of TreeNode objects


Copyright © 2011. All Rights Reserved.