invisibletreemodel.java
来自「Java中Swing界面库中几个类使用的例子」· Java 代码 · 共 59 行
JAVA
59 行
/* (swing1.1) */ package jp.gr.java_conf.tame.swing.tree;import javax.swing.tree.*;/** * @version 1.0 01/12/99 */public class InvisibleTreeModel extends DefaultTreeModel { protected boolean filterIsActive; public InvisibleTreeModel(TreeNode root) { this(root, false); } public InvisibleTreeModel(TreeNode root, boolean asksAllowsChildren) { this(root, false, false); } public InvisibleTreeModel(TreeNode root, boolean asksAllowsChildren ,boolean filterIsActive) { super(root, asksAllowsChildren); this.filterIsActive = filterIsActive; } public void activateFilter(boolean newValue) { filterIsActive = newValue; } public boolean isActivatedFilter() { return filterIsActive; } public Object getChild(Object parent, int index) { if (filterIsActive) { if (parent instanceof InvisibleNode) { return ((InvisibleNode)parent).getChildAt(index,filterIsActive); } } return ((TreeNode)parent).getChildAt(index); } public int getChildCount(Object parent) { if (filterIsActive) { if (parent instanceof InvisibleNode) { return ((InvisibleNode)parent).getChildCount(filterIsActive); } } return ((TreeNode)parent).getChildCount(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?