You may add tree-will-expand listener with addTreeWillExpandListener()
to prevent a tree node from expanding or collapsing.
For example to prevent collapsing:
treeTable.addTreeWillExpandListener(new TreeWillExpandListener() {
public void treeWillExpand(TreeExpansionEvent e)
throws ExpandVetoException {
}
public void treeWillCollapse(TreeExpansionEvent e)
throws ExpandVetoException {
throw new ExpandVetoException(e);
}
});
See How to Write a Tree-Will-Expand Listener for some examples.
JXTreeTable
also has a set of methods for collapsing and expanding tree nodes:
expandPath()
, expandAll()
, collapsePath()
and collapseAll()
. Maybe these can be helpful.