TreeView OpenCloseButton


#1

Is it possible to have the OpenCloseButton show even if there are no children below an item?

I am trying to build something that is like a PropertyPanel but with a list of items instead of PropertyComponents. 

The way I have t working is by creating a tree that is only two items deep. When I draw the first level items I set the background color. If there are no children, there is no OpenCloseButton and the background is white.

Is there a better way to do this?

 


#2

You can probably do this with a LookAndFeel, perhaps?


#3

I am overriding drawTreeviewPlusMinusBox. The problem is it is only called when there are subitems. This leaves the blank white space there.

I tried attaching a small jpg image here but it said "The file could not be uploaded."


#4

Here is what this looks like. Since the Bind node has no children the drawTreeviewPlusMinusBox method is never called so i can't draw the background.

Any ideas?

 


#5

Anybody have any idea how to fix this issue? Maybe there is a different way to do it?


#6

In case anyone else has this problem i figured out the solution.

If you want your drawTreeviewPlusMinusBox  called no matter what you need to return true from mightContainSubItems. Normally you would do something like this

 

return tree.getNumChildren() > 0;

I changed it to this for my app

 


    int id = tree.getProperty("id");
    if (id == 0)
        return true;
    else
        return tree.getNumChildren() > 0;