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

JTree key/value pairs  RSS feed

 
Jason Steele
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTree that I want to display based on a key/value pair.
I want to display the value and hide the key which is a database index. I have looked all over and even googled it. Unless I missed something(totally possible!)...I can't find it. I believe I will have to use extend the DefaultTreeModel but am not sure.
A little help would be greatly appreciated.
 
Jason Steele
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I figured it out....but man it took a while. For those interested, here's what I did:

Then I set the tree cell renderer to TreeCellRendererEx which looks like:

The KeyValuePair class looks like this:

That's it....but like I said, it took me a while. It still needs a bit of work though, as it only accepts KeyValuePair objects now.
I hope others can use this as I do...GREAT for databases.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!