Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Help on Searching a string in JTree

  Asked By: Cory    Date: Nov 26    Category: Java    Views: 2702

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

My code is as following, but it doens't search a string

private DefaultMutableTreeNode findUserObject( Object target ){
DefaultMutableTreeNode root =
DefaultMutableTreeNode node = null;
if( root != null ){
for( Enumeration e = root.breadthFirstEnumeration(); e.hasMoreElements
(); )
DefaultMutableTreeNode current =

if( target.equals(current.getUserObject()) ){
node = current;
return node;
return null;



No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Help on Searching a string in JTree Or get search suggestion and latest updates.