Solved

# Jtree question

Posted on 2001-09-11

hi, I have a simple question

if I know a node in jtree how do I get

its index.

I have a node "addnode" which has three

children.

addnode

--node 1

--node 2

--node 3

when the user selects addNode I want

to get the index of all the children of the selected

node.

i.e I want to get index of node 1,node 2,node 3

I can get index of addnode by

tree.getLeadSelectionRow();

but how do I get indices of the children?

I tried doing this

Object arr [] = node1.getUserObjectPath();

TreePath path = new TreePath(arr);

int index = dragTree.getRowForPath(path);

but I always get index as -1

Thanks