tags:

views:

49

answers:

2

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?

A: 

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

smeg4brains
It does not work still will minimized
A: 

You could extend JTree and create a JExpandedTree which overrides the add and delete methods to call expandTree afterwards.

Pace