• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTree, CheckBox, Programmatically Checking CheckBox

 
Kirt Cathey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All.

Searched high and low for this but couldn't figure it out.....
I am using this http://www.jroller.com/santhosh/date/20050610 code to create a JTree with checkboxes. All is cool, except when I load nodes into the tree I need to programmatically set the check
on the checkbox nodes. Any ideas on how to do this?

--Kirt
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

What about the setSelected(boolean) method? Have you found that?
 
Kirt Cathey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the code that I referred to in the original posting, there are check boxes in the manager and the renderer.

Which one to setSelected with?
When I expose either one and setSelected, nothing changes on the tree.

Repaint issue?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you try posting a comment (question) on the blog?
did you try emailing the author of the code?
 
Kirt Cathey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No and No.... the posting was from 2005. After some thorough reading and much trial and error, I learned a bit about cell renderer. But it look's like there is more than one way to make this happen.
Here is the code I ended up with... but didn't use check boxes - opted for status markers instead.


 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags next time. I've added them for you this time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic