How can I unselect a JTree node selection?

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.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact