Reputation: 8648
I want to keep my jTree file expanded. I using below code to expand the jTree :
public void expandAll(JTree tree) {
int row = 0;
while (row < tree.getRowCount()) {
tree.expandRow(row);
row++;
}
}
It works, but when I add in new file or delete file the jtree collapse back. How can keep the jTree expanded?
Upvotes: 2
Views: 837
Reputation: 43907
You could extend JTree
and create a JExpandedTree
which overrides the add and delete methods to call expandTree
afterwards.
Upvotes: 1
Reputation: 17761
A possibility is to save the expansionState into a local variable in your method and after manipulating the JTree you can reset the expansionState from your local variable.
check here for an example
Upvotes: 0