JTree aufklappen

Guadrion

Mitglied
Hi liebe Leute,
ich hab mir ein eigenes TableTreeModel geschrieben welches wunderbar funktioniert. Ich hab nun einen Listener der mir meldet wenn in meiner Oberfläche was geklickt wird. Ich will nun meinen Baum durchsuchen nach einem bestimmten Pfad, der hinterlegt beziwhungsweise selektiert wird. Wie kann ich das am leichtesten machen? Der Baum soll automatisch, wenn er das richtige Blatt gefunden hat, aufgeklappt werden.

Viele Grüße
 
Hallo,
eventuell helfen dir folgende Methoden der Klasse JTree weiter:

Code:
expandPath
public void expandPath(TreePath path)Ensures that the node identified by the specified path is expanded and viewable. If the last item in the path is a leaf, this will have no effect. 

Parameters:
path - the TreePath identifying a node

Code:
setSelectionPath
public void setSelectionPath(TreePath path)Selects the node identified by the specified path. If any component of the path is hidden (under a collapsed node), and getExpandsSelectedPaths is true it is exposed (made viewable). 

Parameters:
path - the TreePath specifying the node to select
 
Zurück