How can I unselect a JTree node selection?
Created May 4, 2012
Sandip Chitale To unselect all the tree node selection.
Use the following method of JTree.
public void clearSelection();
This works great for SINGLE_TREE_SELECTION mode.
Altenatively you could get the current selection of nodes using the following methods -
public int[] getSelectionRows() // row based
public TreePath[] getSelectionPaths() // tree path based
then remove from the retuned arrays the row index or TreePath that you want to unselect and the use the corresponding 'set' methods.