Search and centralized

I have an application which creates a treeview. They want to be able to do something like a search, it would then highlight and centralized the view to that particular component. Is there anyway to do that?

Thanks!

You’ll need to iterate through your JGoDocument, looking for one of the nodes that satisfies your search.

Once you’ve found a node, you can cause it to be scrolled into view by:

view.scrollRectToVisible(found.getBoundingRect());

How can i iterate through the nodes?

That’s described in the User Guide:

JGoListPosition pos = myDoc.getFirstObjectPos();
while (pos != null) {
JGoObject obj = myDoc.getObjectAtPos(pos);
pos = myDoc.getNextObjectPosAtTop(pos);
if (obj instanceof MyNode) {
MyNode n = (MyNode)obj;
// do something with MyNode n
}
}

Thanks you’ve been a great help