• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree leaf  RSS feed

 
vladislav peichev
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to display a particular JTree leaf with closed folder icon instead of file one?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's probably more than one way to do this, and the choice would depend largely on your TreeModel and its contents. To get better help sooner, post a SSCCE that shows how you build your JTree, and indicate which node you would like to be shown as a folder icon.

By the way, you might want to go through this page of the FAQ.
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DefaultTreeCellRenderer allows you to overwrite the icons. However, changing the leaf icon will change the icons for all leafs.
 
vladislav peichev
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I managed to implement it - I check the user object of the node in my DefaultTreeCellRenderer overriding class and set closed folder icon for the particular node. Thanks for your help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!