Stan
Stan

Reputation: 38265

How to use a tri-state checkbox/TreeItem in Java?

Env: Java SE 6

I am working on an Eclipse RCP application. How do I create TreeItems with tri-state checkbox. Like the Eclipse IDE update package interface. I use SWT TreeItem class now, which only provides API, setChecked(bool), for true/false states.

enter image description here

Upvotes: 0

Views: 771

Answers (1)

greg-449
greg-449

Reputation: 111217

The filled in check box is known as 'grayed'.

With CheckboxTreeViewer use the setGrayed, setGrayChecked, setGrayedElements methods to set grayed items.

With TreeItem use the setGrayed method.

It is up to you to code the logic for determining when a node should be grayed.

Upvotes: 3

Related Questions