• 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

JTree bold all user selected values

 
Greenhorn
Posts: 2
Netbeans IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i am working on my first swing application and am stuck with the below functionality in JTree.

i have created a Jtree from values taken from the DB. the displayed values are linked with a HashMap, so when the user clicks a value(leaf) from the Jtree, the appropriate object will be selected from the Map and the process works fine.

the functionaly which i need help is;
initially when the user first opens the Application, the Jtree values should be displayed in bold. and after the user selected a value, it should be un-bolded. (the requirment is for the user to identify which values he has selected and which are new ).

i have implemented a custom TreeCellRenderer and was able to make the values bold initially and also unbold the selected value(will be unbold only till it is selected) with the below code. but as mentioned, i need to keep the selected values un-bold until the application is closed.(ex-similar functionality as Microsoft Outlook)



will much appreciate any help on this.

Thanks in advance,
Nalaka
jtree.png
[Thumbnail for jtree.png]
Jtree View
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The object you are displaying will need a boolean attribute where it can keep track of whether it's supposed to appear bold or not. Presumably you would set, or toggle, that attribute in the object when the user selects a node containing it. Your TreeCellRenderer would also have to query that attribute to determine whether to display it as bold or not.
 
It's feeding time! Give me the food you were going to give to 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