I have below Tree structure which is sub class of JTree
When the user selects a node, Time in image above, I need to get the Row index (index value = 3) of Demoscrigo(image above) with respect to Wells not from actual Root. Same index will be used to pre-select the row in other UI.
I can get the selected Object but as the nodes has duplicate entries that is making things difficult.
I have tried below options
getRowForPath(new TreePath(selectedNode.getPath()))
getSelectionRows()
this.getModel().getIndexOfChild(userObj, selectedNode);
JavaClientTreeModel treeModel = (JavaClientTreeModel) this.getModel();
selectedNode.getLevel()
this.getLastSelectedPathComponent();
this.getLeadSelectionRow();
But not able to figure out any specific combination. Please suggest me if any other solution is there.
DefaultMutableTreeNodes
(most likely you are using them). Simp,y subtract the row of the "new root" from the row of the node. – weisj