f



How to disable tree node selection

Is there an API to temporarily diable node selection in a JTree?  What I
want is to keep the currently selected node to stay selected and disallow
selecting any other tree nodes.  I would like to be able to switch this
feature on and off programmatically.

Thanks
Bora


0
Bora
6/29/2004 3:42:33 PM
comp.lang.java.gui 8285 articles. 0 followers. Post Follow

1 Replies
1578 Views

Similar Articles

[PageSpeed] 14

you should write your own TreeSelectionModel (better extend
DefaultTreeSelectionModel).
1) Introduce boolean variable - for example:
    boolean freezed;

2) add getter and setter for freezed;

3) override appropriate methods - for example:

public void setSelectionPath(TreePath path) {
    if(freezed) {
        return;
    }
    else {
        super.setSelectionPath(path);
    }
}

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader


0
ak
6/29/2004 3:58:09 PM
Reply: