• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting at multiple selected nodes in JTree

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic