• Post Reply Bookmark Topic Watch Topic
  • New Topic

nodes with no children are displayed as a leaf nodes in JTree

 
sharath kv
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a JTree with lots of parent nodes and children nodes of the parent nodes.Within one parent node I have many other parent nodes with and without children nodes.The parent nodes without children are displayed as leaf nodes,instead of being displayed as parent nodes itself.
I want to display parent nodes as parent nodes only even if it does not contain any children.
PLEASE HELP ME OUT IN THIS REGARD AS THIS IS A VERY CRUCIAL ELEMENT OF MY PROJECT.IF POSSIBLE PLEASE GIVE ME AN EXAMPLE.
THANK YOU
SHARATH
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no need to cry out loud...
have you had a look at TreeModel? if not you should. implement you own (or extend it from DefaultTreeModel). overwrite the method isLeaf(node) and getChildCount(node) etc. see the swing tutorial on JTree. you might want to provide your custom TreeNode implementation as well.
cheers,
Chantal
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!