Saving the tree state

S

soup_or_power

Hi Zero
Thank you for helping me out. I've a new problem now. I am trying to
save the JTree state to a DB. I've narrowed down the following 2
functions. I am wondering about how to save the variable "paths" (pl.
see code below) so that the tree can be recreated. What goes into the
vector?

Thank you


<begin code snippet>

Vector paths





public void saveTreePaths() {



Object path = selectionTree.getModel().getRoot();

paths = new Vector();

TreePath tp = new TreePath(path);

nodes = selectionTree.getExpandedDescendants(tp);

while(nodes.hasMoreElements()) {

paths.add(nodes.nextElement());

}



}







public void reloadTreePath() {

for(int j = 0; j < paths.size(); j++) {

TreePath Path = (TreePath) paths.get(j);

selectionTree.expandPath(Path);

}

}

<end code snippet>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top