• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTree with Checkbox Nodes

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi experts,

I want to develop a Jtree which is having checkbox to every node and label. When user selects a child node then the parent nodes checkbox should also be selected partially.

This tree should look like the tree we see many times in windows based applications.

I wonder how can I do this?.. Please help me in this..

Thanks and Regards,
Lenin
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should be aware of how Swing treats its components. In many cases (JTable, JList, JTree) it uses the renderer/editor model. The renderer is a custom read-only presentation of your info. The editor is a custom writable presentation of your info. This is the way to solve your problem. You should read more about this in Sun Swing Tutorial.

--
./pope
[the_mindstorm]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this might start you off

http://forum.java.sun.com/thread.jsp?forum=57&thread=122006
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TreeCellRenderer is your choice.
 
reply
    Bookmark Topic Watch Topic
  • New Topic