• 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

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

I am looking for some sample codes to add nodes into JTree, where
the nodes could be "JCheckbox with Label" or "Label only". When clicking
on a button, only the nodes with the check in the JCheckbox are
printed.

I created my own cell renderer, then getCellRendererComponent is return JCheckBox on the node that the check box would appear, otherwise return normal JLabel.
It worked but the node is not checkable...
The other problem that I faced is that the icons of the node (like folder file) that comes in the JTree, by default, is not appearing anymore. It's appearing only the check-boxes...

the result should appear like that of eclipse import file system tree, for example...

Thanks for the help
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic