I'm using a JTreeTable taken from the java sun example.. I have the following structure:
+1
+4
+7
which represents the 3 node collapsed..
-1
--2
---3
-4
--5
---6
-7
--8
---9
And this is the structure expanded. I've added a ListSelectionListener to my ListSelectionModel.
Suppose that I select the node "4" from the collapsed structure.. when I'm into the valueChanged(ListSelectionEvent e) method,
e.getFirstIndex() is equal to 1 (because at the index 0 there is the node "1")
But it means that the indexes are not absolutely, but related to the state of the structure. In fact if I expand the structure and after I select again the node "4"
e.getFirstIndex() is equal to 3
In this way I'm not able to univocally identify the selected row in my TreeTable. Do you know how can I solve this problem? Thank you
you need the TreePath to the node, either
TreePath path = treeTable.pathForRow(selected);
or listen directly the TreeSelectionModel. Not sure if that old treeTable exposes it, though. Better use JXTreeTable from the SwingX project, it's gone a big distance since then :-)