• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

multiple node selection in jtree

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a jtree. I have set selection mode as SINGLE_TREE_SELECTION. (f_jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION) . But, on initial load of jtree, I am pre-selecting a node. If the nodes of same id are found, then I'll have to select all the nodes matched. Is it possible to select only a single node(ay, select the first node found) and make some asthetic change (like change the background) for other nodes of similar id?
Thanks
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you could start the tree with multiple selection and change to single selection as soon as the user selects a node, the first time. I think, this is the easiest solution. I am doing that in a table to mark search events - each time a search produces hits, I select all the matching rows (after changing to multiple selection), and as soon as the user clicks in the table, the selection mode is changed bach to single selection. this works very fine and fast.
if you want to change the background of some nodes you will have to implement a TreeCellRenderer that checks for this special ID and paints the background of the nodes appropriately. as the ID is set dynamically you would have to design the API of the renderer accordingly: implement a setID() method and fire an event (from the controller or the treemodel) that notifies the tree to update itself.
chantal
[ November 22, 2002: Message edited by: Chantal Ackermann ]
 
Create symphonies in seed and soil. For this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic