I am using a CheckBoxTree with selection listeners. I want to enable a button when I select a checkbox from tree ( with multiple selections) and after selection if I deselect all of selected checkboxes, then the button should be disabled back. I tried to implement this but just couldn't succeed.
Also, when I get all the selectedPaths, I could see that it also contains a path which I had selected earlier but deselected later. Is there any way to avoid that kind of deselected (once selected but later deselected) path not to appear in the list of selected paths?
Could you please help me to resolve these above two issues?
I am trying with below code:
- Code: Select all
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
//Do Nothing
}
});
tree.getCheckBoxTreeSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
if (!tree.isSelectionEmpty()) {
button1.setEnabled(true);
button2.setEnabled(true);
}
}
});
Thanks,
Mandar