posted 17 years ago
Hi, basically what I am working on is there is one JTree that always contains the full tree (depth 2) for a particular dataset. There is next to this a JTree that is initially empty (except for a root) to which the user can add or remove nodes from the master tree arbitrarily.
If the user clicks on a node in the master tree, the "Select" button is enabled, any selections in the subset tree are cleared, and the user can add to the subset tree, if the user selects a node in the subset tree, the "Unselect" button is enabled, any seletions in the master tree are cleared, and the user can remove from the subset tree, but none of this makes any change to the master tree.
Will want to be able to work at any depth, such that clicking the root node in the master tree and then select will transfer the entire tree to the subset tree, selecting a mid-level node will transfer that node and all of its children to the subset, and selecting a leaf node will transfer only that leaf node (and its parent if it's not already there) to the subset tree. Right now I am focusing on the second of the three problems.
I am finding that doing it once through things work ok, you can add a node and then remove it from the subset tree. Trying to add a second node, or re-adding the original node after it has been added and removed once, seems to change the model yet I cannot seem to get it to display, can't really figure out what would be different in the logic flow the second time around.
Here is the method that is called once the "Select" button has been clicked, and it is determined which node in the master tree was selected (which is passed as the argument nodeToAdd. Thanks if you can shed any light on this.