Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree Node Display problem  RSS feed

 
seema mani
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi I'm facing a problem with the display of the JTree nodes. To display the child nodes of a node, we click the '+' symbol near it. Now my problem is that if a node which is allowed to have child nodes is shown, the '+' symbol appears even if it has no children at present. How do I change this behaviour ? That is I want the '+' sign to appear for a folder node only if it has at least one child.
Thanks a lot
seema
 
Josh Rehman
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally a TreeRenderer will check the TreeModels getChildCount(Object) method to determine how to render nodes. If you are writing your own TreeModel or your own renderer, you need to be sure to implement that method in the model, and check it in the renderer. For more info see:
http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!