• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree  RSS feed

 
joe jean
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using DefaultMutableTreeNode. I set the object for the node using
setUserObject , but I need to concatenate strings to the node and display the concatenated value for the object.

Is there a way to do this , instead of having to override the toString method.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Overriding the toString() method of the object you put into the tree node is certainly the most natural way to do that, and I can't really see why you would not want to do it. But if there is some reason why not, you could probably have your TreeCellRenderer set some different text.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!