Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with JTree and CheckBoxes  RSS feed

Clemens Stich
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!