This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I can't renounce my name. It's on all my stationery! And hinted in this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic