Share this page 

Single selection in a JTreeTag(s): Swing


myJTree.getSelectionModel().
   setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
Also you may want to disable the CTRL-A key which select the entire tree.
[JDK1.2]
KeyStroke ks = KeyStroke.getKeyStroke("ctrl A");
tree.unregisterKeyboardAction(ks);

[JDK1.3+]
KeyStroke ks = KeyStroke.getKeyStroke("ctrl A");
tree.getInputMap().put(ks, "none");