Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

JTree with CheckBox

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to make a JTree with checkboxes. The checkbox selection should be independent of the node selection. i.e. if I click on the node's text part it should be highlighted but the check box should not be ticked/unticked. Ticking/unticking the checkbox should not highlight the node's text part.

Actually when the GUI comes up for the first time i read the file system of a system and displays only the first level, say only the C: drive and its folders in the left pane as tree and on right side pane the files present in C drive in a tabular structure.

Now when i click on the node's text part, node should be highlited and it should fetch the content of the folder and add the subfolders to it and so on. This means I am adding the child nodes on user click.
May be I can have a FolderUserObject which can save the tick/untick as a boolean variable, as i need this at later part.

Please provide me some good sample code soon.
Its very urgent.
Thanks in advance.
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recently researched this topic. Googling 'jtree checkbox' returned many results. I found this example to be very useful.
[ June 08, 2007: Message edited by: Bridget Kennedy ]
 
Lalita Kadambala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem with this example code is it checks box is not there for the parent nodes. Can somebody correct this so that i should have checkboxs through out the tree but the behaviour of the checkbox should ramain same.

Is it possible to remove the if(leaf) check in the renderer?

Please provide me the solution.
Thanks in advance.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic