javax.swing.tree

Class DefaultTreeModel

Implemented Interfaces:
Serializable, TreeModel

public class DefaultTreeModel
extends Object
implements Serializable, TreeModel

DefaultTreeModel

See Also:
Serialized Form

Field Summary

protected boolean
asksAllowsChildren
asksAllowsChildren
protected EventListenerList
listenerList
listenerList
protected TreeNode
root
root

Constructor Summary

DefaultTreeModel(TreeNode root)
Constructor DefaultTreeModel
DefaultTreeModel(TreeNode root, boolean asksAllowsChildren)
Constructor DefaultTreeModel

Method Summary

void
addTreeModelListener(TreeModelListener listener)
Registers a listere to the model.
boolean
asksAllowsChildren()
asksAllowsChildren
protected void
fireTreeNodesChanged(Object source, Object[] path, int[] childIndices, Object[] children)
fireTreeNodesChanged
protected void
fireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children)
fireTreeNodesInserted
protected void
fireTreeNodesRemoved(Object source, Object[] path, int[] childIndices, Object[] children)
fireTreeNodesRemoved
protected void
fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children)
fireTreeStructureChanged
Object
getChild(Object node, int idx)
getChild
int
getChildCount(Object node)
getChildCount
int
getIndexOfChild(Object parent, Object child)
getIndexOfChild
EventListener[]
getListeners(Class listenerType)
Returns the registered listeners of a given type.
TreeNode[]
getPathToRoot(TreeNode value0)
getPathToRoot
protected TreeNode[]
getPathToRoot(TreeNode value0, int value1)
getPathToRoot
Object
getRoot()
getRoot
TreeModelListener[]
getTreeModelListeners()
Returns all registered TreeModelListener listeners.
void
insertNodeInto(MutableTreeNode value0, MutableTreeNode value1, int value2)
insertNodeInto
boolean
isLeaf(Object node)
isLeaf
void
nodeChanged(TreeNode value0)
nodeChanged
void
nodeStructureChanged(TreeNode value0)
nodeStructureChanged
void
nodesChanged(TreeNode value0, int[] value1)
nodesChanged
void
nodesWereInserted(TreeNode value0, int[] value1)
nodesWereInserted
void
nodesWereRemoved(TreeNode value0, int[] value1, Object[] value2)
nodesWereRemoved
void
reload()
reload
void
reload(TreeNode value0)
reload
void
removeNodeFromParent(MutableTreeNode value0)
removeNodeFromParent
void
removeTreeModelListener(TreeModelListener listener)
Removes a listener from the model.
void
setAsksAllowsChildren(boolean value)
setAsksAllowsChildren
void
setRoot(TreeNode root)
setRoot
void
valueForPathChanged(TreePath value0, Object value1)
valueForPathChanged

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

asksAllowsChildren

protected boolean asksAllowsChildren
asksAllowsChildren


listenerList

protected EventListenerList listenerList
listenerList


root

protected TreeNode root
root

Constructor Details

DefaultTreeModel

public DefaultTreeModel(TreeNode root)
Constructor DefaultTreeModel

Parameters:


DefaultTreeModel

public DefaultTreeModel(TreeNode root,
                        boolean asksAllowsChildren)
Constructor DefaultTreeModel

Parameters:

Method Details

addTreeModelListener

public void addTreeModelListener(TreeModelListener listener)
Registers a listere to the model.
Specified by:
addTreeModelListener in interface TreeModel

Parameters:
listener - the listener to add


asksAllowsChildren

public boolean asksAllowsChildren()
asksAllowsChildren

Returns:
boolean


fireTreeNodesChanged

protected void fireTreeNodesChanged(Object source,
                                    Object[] path,
                                    int[] childIndices,
                                    Object[] children)
fireTreeNodesChanged

Parameters:
source - the node being changed
path - the path to the root node
childIndices - the indices of the changed elements
children - the changed elements


fireTreeNodesInserted

protected void fireTreeNodesInserted(Object source,
                                     Object[] path,
                                     int[] childIndices,
                                     Object[] children)
fireTreeNodesInserted

Parameters:
source - the node where new nodes got inserted
path - the path to the root node
childIndices - the indices of the new elements
children - the new elements


fireTreeNodesRemoved

protected void fireTreeNodesRemoved(Object source,
                                    Object[] path,
                                    int[] childIndices,
                                    Object[] children)
fireTreeNodesRemoved

Parameters:
source - the node where nodes got removed-
path - the path to the root node
childIndices - the indices of the removed elements
children - the removed elements


fireTreeStructureChanged

protected void fireTreeStructureChanged(Object source,
                                        Object[] path,
                                        int[] childIndices,
                                        Object[] children)
fireTreeStructureChanged

Parameters:
source - the node where the model has changed
path - the path to the root node
childIndices - the indices of the affected elements
children - the affected elements


getChild

public Object getChild(Object node,
                       int idx)
getChild
Specified by:
getChild in interface TreeModel

Parameters:

Returns:
Object


getChildCount

public int getChildCount(Object node)
getChildCount
Specified by:
getChildCount in interface TreeModel

Parameters:

Returns:
int


getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)
getIndexOfChild
Specified by:
getIndexOfChild in interface TreeModel

Parameters:

Returns:
int


getListeners

public EventListener[] getListeners(Class listenerType)
Returns the registered listeners of a given type.

Parameters:
listenerType - the listener type to return

Returns:
an array of listeners

Since:
1.3


getPathToRoot

public TreeNode[] getPathToRoot(TreeNode value0)
getPathToRoot

Parameters:
value0 - TODO

Returns:
TreeNode[]


getPathToRoot

protected TreeNode[] getPathToRoot(TreeNode value0,
                                   int value1)
getPathToRoot

Parameters:
value0 - TODO
value1 - TODO

Returns:
TreeNode[]


getRoot

public Object getRoot()
getRoot
Specified by:
getRoot in interface TreeModel

Returns:
Object


getTreeModelListeners

public TreeModelListener[] getTreeModelListeners()
Returns all registered TreeModelListener listeners.

Returns:
an array of listeners.

Since:
1.4


insertNodeInto

public void insertNodeInto(MutableTreeNode value0,
                           MutableTreeNode value1,
                           int value2)
insertNodeInto

Parameters:
value0 - TODO
value1 - TODO
value2 - TODO


isLeaf

public boolean isLeaf(Object node)
isLeaf
Specified by:
isLeaf in interface TreeModel

Parameters:

Returns:
boolean


nodeChanged

public void nodeChanged(TreeNode value0)
nodeChanged

Parameters:
value0 - TODO


nodeStructureChanged

public void nodeStructureChanged(TreeNode value0)
nodeStructureChanged

Parameters:
value0 - TODO


nodesChanged

public void nodesChanged(TreeNode value0,
                         int[] value1)
nodesChanged

Parameters:
value0 - TODO
value1 - TODO


nodesWereInserted

public void nodesWereInserted(TreeNode value0,
                              int[] value1)
nodesWereInserted

Parameters:
value0 - TODO
value1 - TODO


nodesWereRemoved

public void nodesWereRemoved(TreeNode value0,
                             int[] value1,
                             Object[] value2)
nodesWereRemoved

Parameters:
value0 - TODO
value1 - TODO
value2 - TODO


reload

public void reload()
reload


reload

public void reload(TreeNode value0)
reload

Parameters:
value0 - TODO


removeNodeFromParent

public void removeNodeFromParent(MutableTreeNode value0)
removeNodeFromParent

Parameters:
value0 - TODO


removeTreeModelListener

public void removeTreeModelListener(TreeModelListener listener)
Removes a listener from the model.
Specified by:
removeTreeModelListener in interface TreeModel

Parameters:
listener - the listener to remove


setAsksAllowsChildren

public void setAsksAllowsChildren(boolean value)
setAsksAllowsChildren

Parameters:


setRoot

public void setRoot(TreeNode root)
setRoot

Parameters:


valueForPathChanged

public void valueForPathChanged(TreePath value0,
                                Object value1)
valueForPathChanged
Specified by:
valueForPathChanged in interface TreeModel

Parameters:
value0 - TODO
value1 - TODO


DefaultTreeModel.java -- Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.