⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaulttreemodel.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* DefaultTreeModel.java --    Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe 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, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING. If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library. Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule. An independent module is a module which is not derived fromor based on this library. If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so. If you do not wish to do so, delete thisexception statement from your version. */package javax.swing.tree;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Serializable;import java.util.EventListener;import javax.swing.event.EventListenerList;import javax.swing.event.TreeModelEvent;import javax.swing.event.TreeModelListener;import javax.swing.tree.DefaultMutableTreeNode;/** * DefaultTreeModel *  * @author Andrew Selkirk */public class DefaultTreeModel    implements Serializable, TreeModel{  static final long serialVersionUID = -2621068368932566998L;  /**   * root   */  protected TreeNode root = null;  /**   * listenerList   */  protected EventListenerList listenerList = new EventListenerList();  /**   * asksAllowsChildren   */  protected boolean asksAllowsChildren;  /**   * Constructor DefaultTreeModel   *    * @param root the tree root.   */  public DefaultTreeModel(TreeNode root)  {    if (root == null)      root = new DefaultMutableTreeNode();    setRoot(root);  }  /**   * Constructor DefaultTreeModel   *    * @param root the tree root.   * @param asksAllowsChildren TODO   */  public DefaultTreeModel(TreeNode root, boolean asksAllowsChildren)  {    setRoot(root);    this.asksAllowsChildren = asksAllowsChildren;  }  /**   * writeObject   *    * @param obj the object.   * @exception IOException TODO   */  private void writeObject(ObjectOutputStream obj) throws IOException  {    // TODO  }  /**   * readObject   *    * @param value0 TODO   * @exception IOException TODO   * @exception ClassNotFoundException TODO   */  private void readObject(ObjectInputStream value0) throws IOException,      ClassNotFoundException  {    // TODO  }  /**   * asksAllowsChildren   *    * @return boolean   */  public boolean asksAllowsChildren()  {    return asksAllowsChildren;  }  /**   * setAsksAllowsChildren   *    * @param value TODO   */  public void setAsksAllowsChildren(boolean value)  {    asksAllowsChildren = value;  }  /**   * setRoot   *    * @param root the root node.   */  public void setRoot(TreeNode root)  {    // Sanity Check    if (root == null)      {        throw new IllegalArgumentException("null root");      }    // Set new root    this.root = root;  }  /**   * getRoot   *    * @return Object   */  public Object getRoot()  {    return root;  }  /**   * getIndexOfChild   *    * @param parent TODO   * @param child TODO   * @return int   */  public int getIndexOfChild(Object parent, Object child)  {    for (int i = 0; i < getChildCount(parent); i++)      {        if (getChild(parent, i).equals(child))          return i;      }    return -1;  }  /**   * getChild   *    * @param node TODO   * @param idx TODO   * @return Object   */  public Object getChild(Object node, int idx)  {    if (node instanceof TreeNode)      return ((TreeNode) node).getChildAt(idx);    else      return null;  }  /**   * getChildCount   *    * @param node TODO   * @return int   */  public int getChildCount(Object node)  {    if (node instanceof TreeNode)      return ((TreeNode) node).getChildCount();    else      return 0;  }  /**   * isLeaf   *    * @param node TODO   * @return boolean   */  public boolean isLeaf(Object node)  {    if (node instanceof TreeNode)      return ((TreeNode) node).isLeaf();    else      return true;  }  /**   * Invoke this method if you've modified the TreeNodes upon    * which this model depends. The model will notify all of its    * listeners that the model has changed.   */  public void reload()  {    // TODO  }  /**   * Invoke this method if you've modified the TreeNodes upon    * which this model depends. The model will notify all of its    * listeners that the model has changed.   *    * @param node - TODO   */  public void reload(TreeNode node)  {    // TODO  }  /**   * Messaged when the user has altered the value for the item    * identified by path to newValue. If newValue signifies a truly new    * value the model should post a treeNodesChanged event.   * This sets the user object of the TreeNode identified by    * path and posts a node changed. If you use custom user objects    * in the TreeModel you're going to need to subclass this and set    * the user object of the changed node to something meaningful.   *    * @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)  {    Object node = path.getLastPathComponent();    if (node instanceof MutableTreeNode)      {        ((MutableTreeNode) node).setUserObject(newValue);        int[] ci = null;        Object[] c = null;         Object[] parentPath = path.getPath();        if (path.getPathCount() > 1)          {            Object parent = ((TreeNode) node).getParent();            ci = new int[1];            ci[0] = getIndexOfChild(parent, node);            node = newValue;            path = path.getParentPath().pathByAddingChild(node);            c = new Object[1];            c[0] = node;            parentPath = path.getParentPath().getPath();          }        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -