How can I search a specific string inside JTree node/children? I mean
when I input a word, the matched word will be hightlighted in the
JTree.
My code is as following, but it doens't search a string
private DefaultMutableTreeNode findUserObject( Object target ){
DefaultMutableTreeNode root =
(DefaultMutableTreeNode)fileTree.getModel().getRoot();
DefaultMutableTreeNode node = null;
if( root != null ){
for( Enumeration e = root.breadthFirstEnumeration(); e.hasMoreElements
(); )
{
DefaultMutableTreeNode current =
(DefaultMutableTreeNode)e.nextElement();
if( target.equals(current.getUserObject()) ){
node = current;
return node;
}
}
}
return null;
}