문제

To prevent a JTree node from collapsing, you can use the setExpandedState() method.

I dont see a similar method for the SwingX JXTreeTable class, and it seems that JXTreeTable doesnt extend JXTree (which extends JTree).

Any suggestions as to how I can prevent a root node from collapsing on a JXTreeTable?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top