I am building a treetable
using JXTreeTabble
and I want to disable/able menu
items depending on the selected value. So, I tried to put this code in my table model
:
public Object getValueAt(int index) {
if (index >= 0 && index < root.getSize()){
return root.get(index);
}
return null;
}
The problem
The above only works if the contents of the table
are not expanded. Because the index
of the selected row
might be larger than the size
of the table model
(model can have two items and row can have 10 when everything is expanded). Also, the object type
of the parent
is different from the children
(think of a book with chapters as it children).
What would you suggest as a way to do the above correctly?
The indexes may differ in the view and the model. You have to adjust the selected row's index first using
convertRowIndextToModel()