Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

incremental search on jtree

843806May 27 2008 — edited May 30 2008
Hi, I've been working on building a incremental search for my jtree that is built in an XML file.

When the tree is loaded I want the user to be able to be able to search the tree. Currently I can search the tree if it is expanded. But i want it to search all nodes and child nodes w/o expanding. I tried to expanding the tree, but it becomes very slow.

Also It only finds the first matching node. Any help would be appreciated.

This is what performs the search:
String prefix = this.jTextField1.getText();

    for (int i = 0; i < tree.getRowCount(); i++) {
        TreePath path = tree.getNextMatch(prefix, i, Position.Bias.Forward);
        tree.expandPath(path);
        tree.setSelectionPath(path);
        tree.makeVisible(path);
    }
thanks,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 27 2008
Added on May 27 2008
4 comments
260 views