Prevent JTree collapsingTag(s): Swing

myJTree.addTreeWillExpandListener
  (new TreeWillExpandListener() {
    public void treeWillExpand(TreeExpansionEvent e) { }
    public void treeWillCollapse(TreeExpansionEvent e)
         throws ExpandVetoException {
     throw new ExpandVetoException(e, "you can't collapse this JTree");
     }
    });




If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2012
[ home ]