home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 November
/
Chip_1998-11_cd.bin
/
tema
/
Cafe
/
jfc.bin
/
TreeModel.java
< prev
next >
Wrap
Text File
|
1998-02-26
|
4KB
|
113 lines
/*
* @(#)TreeModel.java 1.10 98/01/11
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
package com.sun.java.swing.tree;
import com.sun.java.swing.event.*;
/**
* The interface that defines a suitable data model for a JTree.
*
* @version 1.10 01/11/98
* @author Rob Davis
* @author Ray Ryan
*/
public interface TreeModel
{
/**
* Returns the root of the tree. Returns null only if the tree has
* no nodes.
*
* @return the root of the tree
*/
public Object getRoot();
/**
* Returns the child of <I>parent</I> at index <I>index</I> in the parent's
* child array. <I>parent</I> must be a node previously obtained from
* this data source.
*
* @param parent a node in the tree, obtained from this data source
* @return the child of <I>parent</I> at index <I>index</I>
*/
public Object getChild(Object parent, int index);
/**
* Returns the number of children of <I>parent</I>. Returns 0 if the node
* is a leaf or if it has no children. <I>parent</I> must be a node
* previously obtained from this data source.
*
* @param parent a node in the tree, obtained from this data source
* @return the number of children of the node <I>parent</I>
*/
public int getChildCount(Object parent);
/**
* Returns true if <I>node</I> is a leaf. It is possible for this method
* to return false even if <I>node</I> has no children. A directory in a
* filesystem, for example, may contain no files; the node representing
* the directory is not a leaf, but it also has no children.
*
* @param node a node in the tree, obtained from this data source
* @return true if <I>node</I> is a leaf
*/
public boolean isLeaf(Object node);
/**
* Messaged when the user has altered the value for the item identified
* by <I>path</I> to <I>newValue</I>. If <I>newValue</I> signifies
* a truly new value the model should post a treeNodesChanged
* event.
*
* @param path path to the node that the user has altered.
* @param newValue the new value from the TreeCellEditor.
*/
public void valueForPathChanged(TreePath path, Object newValue);
/**
* Returns the index of child in parent.
*/
public int getIndexOfChild(Object parent, Object child);
//
// Change Events
//
/**
* Adds a listener for the TreeModelEvent posted after the tree changes.
*
* @see #removeTreeModelListener
* @param l the listener to add
*/
void addTreeModelListener(TreeModelListener l);
/**
* Removes a listener previously added with <B>addTreeModelListener()</B>.
*
* @see #addTreeModelListener
* @param l the listener to remove
*/
void removeTreeModelListener(TreeModelListener l);
}