Groovy Documentation

com.wordpress.tipsforjava.swing.tree
[Java] Class ComponentTreeModel

java.lang.Object
  javax.swing.tree.DefaultTreeModel
      com.wordpress.tipsforjava.swing.tree.ComponentTreeModel
All Implemented Interfaces:
Serializable

public class ComponentTreeModel
extends DefaultTreeModel

A tree data model that reproduces the structure of a GUI to reveal the hierarchical placement of components in containers. Also provides a static method to facilitate adding such a hierarchy at a specified node in an existing DefaultTreeModel.

Extends DefaultTreeModel.

Authors:
Rob Camick
Darryl Burke
Version:
1.0 11/15/08


Constructor Summary
ComponentTreeModel(JComponent container)

Creates a new tree model with a specified JComponent as the root, including nested components at all levels.

ComponentTreeModel(JComponent container, boolean nested)

Creates a new tree model with a specified JComponent as the root, optionally including nested components.

private ComponentTreeModel(JComponent container, DefaultMutableTreeNode root, boolean nested)

private constructor for aligning the public constructors with the static method getComponentTreeModel

 
Method Summary
private static void addNodes(JComponent container, DefaultTreeModel model, DefaultMutableTreeNode root, boolean nested)

private method to obtain the hierarchy devolving from the root container and add nodes to the tree accordingly.

static DefaultTreeModel getComponentTreeModel(JComponent container, DefaultTreeModel model, DefaultMutableTreeNode root, boolean nested)

Invoked to create a new model or to add a JComponent's hierarchy to an existing DefaultTreeModel.

 
Methods inherited from class DefaultTreeModel
getListeners, getRoot, getChildCount, getPathToRoot, isLeaf, getChild, reload, reload, setRoot, asksAllowsChildren, setAsksAllowsChildren, getIndexOfChild, valueForPathChanged, insertNodeInto, removeNodeFromParent, nodeChanged, nodesWereInserted, nodesWereRemoved, nodesChanged, nodeStructureChanged, addTreeModelListener, removeTreeModelListener, getTreeModelListeners, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Constructor Detail

ComponentTreeModel

public ComponentTreeModel(JComponent container)
Creates a new tree model with a specified JComponent as the root, including nested components at all levels.
Parameters:
container - the JComponent to be placed at the root of the tree
See Also:
DefaultTreeModel


ComponentTreeModel

public ComponentTreeModel(JComponent container, boolean nested)
Creates a new tree model with a specified JComponent as the root, optionally including nested components.
Parameters:
container - the JComponent to be placed at the root of the tree
nested - true to include nested components, false otherwise


ComponentTreeModel

private ComponentTreeModel(JComponent container, DefaultMutableTreeNode root, boolean nested)
private constructor for aligning the public constructors with the static method getComponentTreeModel


 
Method Detail

addNodes

private static void addNodes(JComponent container, DefaultTreeModel model, DefaultMutableTreeNode root, boolean nested)
private method to obtain the hierarchy devolving from the root container and add nodes to the tree accordingly.


getComponentTreeModel

public static DefaultTreeModel getComponentTreeModel(JComponent container, DefaultTreeModel model, DefaultMutableTreeNode root, boolean nested)
Invoked to create a new model or to add a JComponent's hierarchy to an existing DefaultTreeModel.
Parameters:
container - the JComponent to be placed at the root of the tree or added at a node of an existing tree
model - a DefaultTreeModel to which the container's GUI hierarchy will be added, or null to create a new model
root - the node on the model to which the containerand its hierarchy will be added, or null for a model that has the container as its root
nested - true to include nested components, false otherwise
Returns:
the model, or a new DefaultTreeModel if the model parameter is null


 

Groovy Documentation