Here you can find the source of findChildNode(TreeModel model, Object node, String text)
Parameter | Description |
---|---|
model | the TreeModel to search |
node | the node to search below |
text | the text associated with the required node |
static Object findChildNode(TreeModel model, Object node, String text)
//package com.java2s; // it under the terms of the GNU General Public License as published by import javax.swing.tree.TreeModel; public class Main { /**// w w w .j a v a 2 s .c om * Returns the node with the given text below the given node in the specified TreeModel * @param model * the TreeModel to search * @param node * the node to search below * @param text * the text associated with the required node * @return * the required node, if found; otherwise null */ static Object findChildNode(TreeModel model, Object node, String text) { for (int i = 0; i < model.getChildCount(node); i++) { Object currNode = model.getChild(node, i); if (currNode.toString() != null && currNode.toString().equals(text)) return currNode; } return null; } }