In my program, I have 2 JTrees and there is a common treeselection listener for both. The problem happens when I select a node in the first tree and then immediately select a node in the second tree.Now if I were to go back and select the same node in the first tree that was initially selected, nothing happens. How do I solve this? Is there a way to unselect a node at the end of a valueChanged event handler?
After Editing:
Now if I only do
if ( tree == tree1 ){
if(!tree2.isSelectionEmpty()){
tree2.clearSelection();
}
} else {
if(!tree1.isSelectionEmpty()){
tree1.clearSelection();
}
}
The first time I select the tree it works fine. But the second time if I select from a different tree, the listener gets fired twice and I have to double click to select it. Any clue why?