Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Enumeration;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;

public class Main {
    public static DefaultMutableTreeNode buscarNodeByNombre(JTree jtree, String nodeStr) {
        DefaultMutableTreeNode node = null;
        TreeNode root = (TreeNode) jtree.getModel().getRoot();
        Enumeration<?> e = root.children();
        while (e.hasMoreElements()) {
            node = (DefaultMutableTreeNode) e.nextElement();
            if ((node.getUserObject().toString()).contains(nodeStr)) {
                return node;
            }
        }
        return null;
    }
}