• 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 wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Problems with JTree and CheckBoxes

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

I searched the forum and found a few topics about this subject, but it didn't help me on my problem.
I wrote an own tree cell renderer, which places a check box after my nodes. My first problem was, that the String representatios of the nodes have different length and because of that my checkboxes of course weren't centered but they were different aligned. I hope you understand what I mean. I then wrote this renderer and it worked quite good (but I am sure, that there is a much better solution):



As you see I just set the label size to a fixed size. Because of that then all checkboxes are centered.

Without an editor I cannot change the checkboxes, so I have written also an editor. But here is my problem. When I want to click on a checkbox, I of course click on the checkbox, but then it suddenly moves a little bit to the right. After that when I click again at this checkBox, I can select/deselect it, and it moves a little bit back right again, so that it is now at it's originial place...
That's very annoying...
I think the problem is the code in my renderer, because if I just set the text to the label, and dont make any changes to the size of the label, then it works fine. But I want to have my checkboxes centered.. Can anyone please help me about that ?

P.S. I didn't post the code from the editor, because there are 3 classes, and I copy&paste that code more or less from a book (JAVA2 Mastering the JFC). If it's needed I will post it too... I don't really understand this stuff at all...
[ December 28, 2005: Message edited by: Clemens Stich ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic