Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree bold all user selected values  RSS feed

 
nalaka dhar
Greenhorn
Posts: 2
Java Netbeans IDE Postgres Database
  • Mark post as helpful
  • send pies
  • 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
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Likes 3
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!