Java JTree Node ApplyFilter(DefaultMutableTreeNode node, String filter)

Here you can find the source of ApplyFilter(DefaultMutableTreeNode node, String filter)

Description

Apply Filter

License

Open Source License

Declaration

public static void ApplyFilter(DefaultMutableTreeNode node, String filter) 

Method Source Code

//package com.java2s;
/**//from  ww w.  jav  a 2 s. c  o m
 * CEDP: Computer Evaluator for Dependability and Performance
 * This file is distributed under the University of Illinois Open Source
 * License. See LICENSE.TXT for details.
 */

import javax.swing.tree.DefaultMutableTreeNode;

public class Main {
    public static void ApplyFilter(DefaultMutableTreeNode node, String filter) {
        if (node.getChildCount() == 0) {
            if (!node.toString().endsWith(filter)) {
                node.removeFromParent();
            }
            return;
        }

        for (int i = 0; i < node.getChildCount(); i++) {
            ApplyFilter((DefaultMutableTreeNode) node.getChildAt(i), filter);
        }
    }
}

Related

  1. addChildNode(DefaultMutableTreeNode parent, Object child)
  2. addCloneNode(DefaultMutableTreeNode srcNode, DefaultMutableTreeNode root)
  3. cloneTreeNode(DefaultMutableTreeNode srcNode)
  4. collapseSubTree(JTree tree, DefaultMutableTreeNode startNode, DefaultTreeModel model)
  5. contains(final JTree tree, final TreeNode node)
  6. copyDMTreeNode(DefaultMutableTreeNode out, DefaultMutableTreeNode in)