Jtree - node from path question

T

Tim

Hi

I extended the defaultrTreeModel and used my own objects as nodes in
the tree -
the problem I have now that I want to retrofit my tree with dynamic
addition of nodes is that is that when I call
myTreePath.getLastPathComponent() I get my own object back and not a
reference to a node (which I want so I can add a node to it)

i cant find a way of getting the node from a treepath !!

Please help !!

Tim
 
X

xarax

Tim said:
Hi

I extended the defaultrTreeModel and used my own objects as nodes in
the tree -
the problem I have now that I want to retrofit my tree with dynamic
addition of nodes is that is that when I call
myTreePath.getLastPathComponent() I get my own object back and not a
reference to a node (which I want so I can add a node to it)

i cant find a way of getting the node from a treepath !!

Please help !!

Tim

You wrote that your own objects are the nodes, so you
*are* getting the node. If you need something else
that represents a "node", then make that thing a field
in your object. When you get your object, look at the
field in your object for the "node" thing.
 
T

Tim

Are you saying that if I use my own object then there is no
DefaultMutableTreeNode at that point in the tree - only my object ???
I think I see a light bulb !! But how do you add other objects as
children to my object ??

Thanks
Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top