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

📄 abstracttreemodel.java

📁 人力资源管理信息系统 论文和源代码 人力资源管理系统由人事管理、考勤管理、招聘管理、培训管理、系统管理5部分组成
💻 JAVA
字号:
package net.sf.hibern8ide.swing; import javax.swing.event.TreeModelEvent;import javax.swing.event.TreeModelListener;import javax.swing.event.EventListenerList;import javax.swing.tree.TreeModel;import javax.swing.tree.TreePath;/** * Abstract class implementing the support for TreeModelEvents * and TreeModelListeners. The code is partly snipped from the * implementation of DefaultTreeModel. * * @version $Revision: 1.1 $ **/public abstract class AbstractTreeModel implements TreeModel {    private EventListenerList listenerList = new EventListenerList();    /**     * Adds a listener for the TreeModelEvent posted after the tree changes.     *     * @see     #removeTreeModelListener     * @param   l       the listener to add     */    public void addTreeModelListener(TreeModelListener l) {        listenerList.add(TreeModelListener.class, l);    }    /**     * Removes a listener previously added with <B>addTreeModelListener()</B>.     *     * @see     #addTreeModelListener     * @param   l       the listener to remove     */      public void removeTreeModelListener(TreeModelListener l) {        listenerList.remove(TreeModelListener.class, l);    }    /**      * 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) {        throw new RuntimeException("AbstractTreeModel.valueForPathChanged: you MUST override this when using a TreeCellEditor!");    }    /*     * Notify all listeners that have registered interest for     * notification on this event type.  The event instance      * is lazily created using the parameters passed into      * the fire method.     * @see EventListenerList     */    protected void fireTreeNodesChanged(Object source, Object[] path,                                         int[] childIndices,                                         Object[] children) {        // Guaranteed to return a non-null array        Object[] listeners = listenerList.getListenerList();        TreeModelEvent e = null;        // Process the listeners last to first, notifying        // those that are interested in this event        for (int i = listeners.length-2; i>=0; i-=2) {            if (listeners[i]==TreeModelListener.class) {                // Lazily create the event:                if (e == null)                    e = new TreeModelEvent(source, path,                                            childIndices, children);                ((TreeModelListener)listeners[i+1]).treeNodesChanged(e);            }                  }    }    /*     * Notify all listeners that have registered interest for     * notification on this event type.  The event instance      * is lazily created using the parameters passed into      * the fire method.     * @see EventListenerList     */    protected void fireTreeNodesInserted(Object source, Object[] path,                                         int[] childIndices,                                         Object[] children) {        // Guaranteed to return a non-null array        Object[] listeners = listenerList.getListenerList();        TreeModelEvent e = null;        // Process the listeners last to first, notifying        // those that are interested in this event        for (int i = listeners.length-2; i>=0; i-=2) {            if (listeners[i]==TreeModelListener.class) {                // Lazily create the event:                if (e == null)                    e = new TreeModelEvent(source, path,                                            childIndices, children);                ((TreeModelListener)listeners[i+1]).treeNodesInserted(e);            }                  }    }    /*     * Notify all listeners that have registered interest for     * notification on this event type.  The event instance      * is lazily created using the parameters passed into      * the fire method.     * @see EventListenerList     */    protected void fireTreeNodesRemoved(Object source, Object[] path,                                         int[] childIndices,                                         Object[] children) {        // Guaranteed to return a non-null array        Object[] listeners = listenerList.getListenerList();        TreeModelEvent e = null;        // Process the listeners last to first, notifying        // those that are interested in this event        for (int i = listeners.length-2; i>=0; i-=2) {            if (listeners[i]==TreeModelListener.class) {                // Lazily create the event:                if (e == null)                    e = new TreeModelEvent(source, path,                                            childIndices, children);                ((TreeModelListener)listeners[i+1]).treeNodesRemoved(e);            }                  }    }    /*     * Notify all listeners that have registered interest for     * notification on this event type.  The event instance      * is lazily created using the parameters passed into      * the fire method.     * @see EventListenerList     */    protected void fireTreeStructureChanged(Object source, Object[] path,                                             int[] childIndices,                                             Object[] children) {        // Guaranteed to return a non-null array        Object[] listeners = listenerList.getListenerList();        TreeModelEvent e = null;        // Process the listeners last to first, notifying        // those that are interested in this event        for (int i = listeners.length-2; i>=0; i-=2) {            if (listeners[i]==TreeModelListener.class) {                // Lazily create the event:                if (e == null)                    e = new TreeModelEvent(source, path,                                            childIndices, children);                ((TreeModelListener)listeners[i+1]).treeStructureChanged(e);            }                  }    }    }

⌨️ 快捷键说明

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