Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting at multiple selected nodes in JTree  RSS feed

 
kate damond
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a JTree that allows mutliple selections. I need to iterate through each of the selected nodes and do some processing on them. I thought I'd add them to a hashMap. Unfortunatley, I'm having trouble getting at the nodes themselves. looking back at a similar problem I tackled a while ago, I got round it by using tree.getLastSelectedPathComponent().
I can't generalise to get at all the selected Componenets though.
I can get at all the selected paths though. Does this help ? Can I get at the node, from its TreePath ?
Cheers,
Kate
I
 
Matt Hansen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to get a node from the path using TreePath.getLastPathComponent(). I believe it returns the node at the end of the path.
 
kate damond
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes - you're absolutely right. It seems so simple in retrospect : I had read 'getLastComponentPath()' as getting the last PATH in a multiple selection of paths rather than getting the last COMPONENT in a path !
It's working now, thanks
Kate
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!