# com.bea.wlw.netui.tags.html
TreeNode Class

public class TreeNode
extends `Object`
implements `Serializable`

An individual node of a `Tree`, and rendered by that Tree instance.

Hierarchy
  `Object`
  `TreeNode`

All Implemented Interfaces
  `Serializable`

## Field Summary

`protected `String`` | `action` The action invoked if this node is selected by the user.
`protected `ArrayList`` | `children` The set of child `TreeControlNodes` for this node, in the order that they should be displayed.
`public static final `String`` | `EXPAND_NODE` String
`protected boolean` | `expanded` Is this node currently expanded?
`protected `String`` | `href` String
`protected `String`` | `icon` The pathname to the icon file displayed when this node is visible, relative to the image directory for our images.
`protected `String`` | `label` The label that will be displayed when this node is visible.
`protected boolean` | `last` Is this the last node in the set of children for our parent node?
`protected `String`` | `name` The unique (within the entire tree) name of this node.
`protected `TreeNode`` | `parent` The parent node of this node, or `null` if this is the root node.
`protected boolean` | `selected` Is this node currently selected?
`public static final `String`` | `SELECTED_NODE` String
`protected `String`` | `target` The window target for the hyperlink identified by the `action` property, if this node is selected by the user.
`protected int` | `width` The display width necessary to display this item (if it is visible).

## Constructor Summary

TreeNode(`String` icon, `String` label, `String` action, `String` href, `String` target, boolean expanded) Construct a new TreeNode with the specified parameters.

## Method Summary

`public void` | `addChild`(`TreeNode` child) Add a new child node to the end of the list.
`public void` | `addChild`(int offset, `TreeNode` child) Add a new child node at the specified position in the child list.
`public void` | `collapse`() Code that runs when the node is collapsed.
`public void` | `expand`() Code that runs when the node is expanded.
`public `String`` | `getAction`() Gets the action invoked if this node is selected by the user.
`public `TreeNode`` | `getChild`(int index) Return the child node at the given zero-relative index.
`public `TreeNode`[]` | `getChildren`() Return the set of child nodes for this node.
`public `String`` | `getHref`() Gets the hyperlink to which control will be directed if this node is selected by the user.
`public `String`` | `getIcon`() Gets the pathname to the icon file displayed when this node is visible, relative to the image directory for the images.
`public `String`` | `getLabel`() Gets the label that will be displayed when this node is visible.
`public `TreeNode`` | `getParent`() Gets the parent node of this node, or `null` if this is the root node.
`public `TreeNode`` | `getRoot`(`TreeNode` node) Gets the root node of this tree.
`public `String`` | `getTarget`() Gets the window target for the hyperlink identified by the `action` property, if this node is selected.
`public int` | `getWidth`() Gets the display width necessary to display this item (if it is visible).
`public boolean` | `isExpanded`() Gets if this node is currently expanded.
`public boolean` | `isLast`() Gets whether or not this is the last node in the set of children for the parent node.
`public boolean` | `isLeaf`() Gets whether or not this a "leaf" node (i.e. one with no children)
`public boolean` | `isSelected`() Gets whether this node currently selected.
`public void` | `removeChild`(int offset) Remove the child node (and all children of that child) at the specified position in the child list.
`public void` | `removeChild`(`TreeNode` child) Remove the specified child node.
`public void` | `setExpanded`(boolean expanded) Sets if this node is currently expanded.
`public void` | `setParent`(`TreeNode` parent) Sets the parent node of this node.
`public void` | `setSelected`(boolean selected) Sets whether this node currently selected.

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Detail

### action

    protected String action

  The action invoked if this node is selected by the user.

### children

    protected ArrayList children

  The set of child `TreeControlNodes` for this node, in the order that they should be displayed.

### EXPAND_NODE

    public static final String EXPAND_NODE

### expanded

    protected boolean expanded

  Is this node currently expanded?

### href

    protected String href

### icon

    protected String icon

  The pathname to the icon file displayed when this node is visible, relative to the image directory for our images.

### label

    protected String label

  The label that will be displayed when this node is visible.

### last

    protected boolean last

  Is this the last node in the set of children for our parent node?

### name

    protected String name

  The unique (within the entire tree) name of this node.

### parent

    protected TreeNode parent

  The parent node of this node, or `null` if this is the root node.

### selected

    protected boolean selected

  Is this node currently selected?

### SELECTED_NODE

    public static final String SELECTED_NODE

### target

    protected String target

  The window target for the hyperlink identified by the `action` property, if this node is selected by the user.

### width

    protected int width

  The display width necessary to display this item (if it is visible). If this item is not visible, the calculated width will be that of our most immediately visible parent.

## Constructor Detail

### TreeNode

    public TreeNode(String icon,
                    String label,
                    String action,
                    String href,
                    String target,
                    boolean expanded)

  Construct a new TreeNode with the specified parameters.

## Method Detail

### addChild(TreeNode) Method

    public void addChild(TreeNode child)
         throws IllegalArgumentException

Add a new child node to the end of the list.

#### Parameters

child
  The new child node

#### Exceptions

``IllegalArgumentException``
  if the name of the new child node is not unique

### addChild(int, TreeNode) Method

    public void addChild(int offset,
                         TreeNode child)
         throws IllegalArgumentException

Add a new child node at the specified position in the child list.

#### Parameters

offset
  Zero-relative offset at which the new node should be inserted

child
  The new child node

#### Exceptions

``IllegalArgumentException``
  if the name of the new child node is not unique

### collapse() Method

    public void collapse()

Code that runs when the node is collapsed.

### expand() Method

    public void expand()

Code that runs when the node is expanded.

### getAction() Method

    public String getAction()

Gets the action invoked if this node is selected by the user.

#### Returns

the action

### getChild(int) Method

    public TreeNode getChild(int index)

Return the child node at the given zero-relative index.

#### Parameters

index
  The child node index

#### Returns

the child node

### getChildren() Method

    public TreeNode[] getChildren()

Return the set of child nodes for this node.

#### Returns

the child node array

### getHref() Method

    public String getHref()

Gets the hyperlink to which control will be directed if this node is selected by the user.

#### Returns

the action

### getIcon() Method

    public String getIcon()

Gets the pathname to the icon file displayed when this node is visible, relative to the image directory for the images.

#### Returns

the icon pathname

### getLabel() Method

    public String getLabel()

Gets the label that will be displayed when this node is visible.

#### Returns

the label

### getParent() Method

    public TreeNode getParent()

Gets the parent node of this node, or `null` if this is the root node.

#### Returns

the TreeNode parent

### getRoot(TreeNode) Method

    public TreeNode getRoot(TreeNode node)

Gets the root node of this tree.

#### Parameters

node
  The TreeNode to start from

#### Returns

The root node

### getTarget() Method

    public String getTarget()

Gets the window target for the hyperlink identified by the `action` property, if this node is selected.

#### Returns

the window target

### getWidth() Method

    public int getWidth()

Gets the display width necessary to display this item (if it is visible). If this item is not visible, the calculated width will be that of our most immediately visible parent.

#### Returns

the display width

### isExpanded() Method

    public boolean isExpanded()

Gets if this node is currently expanded.

#### Returns

the expanded state

### isLast() Method

    public boolean isLast()

Gets whether or not this is the last node in the set of children for the parent node.

#### Returns

if this is the last or not

### isLeaf() Method

    public boolean isLeaf()

Gets whether or not this a "leaf" node (i.e. one with no children)

#### Returns

if this is the last or not

### isSelected() Method

    public boolean isSelected()

Gets whether this node currently selected.

#### Returns

the selected state

### removeChild(int) Method

    public void removeChild(int offset)

Remove the child node (and all children of that child) at the specified position in the child list.

#### Parameters

offset
  Zero-relative offset at which the existing node should be removed

### removeChild(TreeNode) Method

    public void removeChild(TreeNode child)

Remove the specified child node. All of the children of this child node will also be removed.

#### Parameters

child
  Child node to be removed

### setExpanded(boolean) Method

    public void setExpanded(boolean expanded)

Sets if this node is currently expanded.

#### Parameters

expanded
  - the expanded state

### setParent(TreeNode) Method

    public void setParent(TreeNode parent)

Sets the parent node of this node.

#### Parameters

parent
  - the TreeNode parent

### setSelected(boolean) Method

    public void setSelected(boolean selected)

Sets whether this node currently selected.

#### Parameters

selected
  - the selected state