Use check boxes in a Swing JTree.
Java Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src Happy New Year 2017 Feb 28, 2017
LICENSE.txt Happy New Year 2017 Feb 28, 2017
pom.xml POM: update pom-scijava parent to 17.1.1 Nov 1, 2017

Swing Checkbox Tree

A check box tree package based on John Zukowski's CheckBox Node Tree Sample code.

You can mix and match DefaultMutableTreeNode and CheckBoxNodeData node types. It also allows check box nodes as non-leaf nodes.

It uses a JCheckBox + JLabel in a JPanel to differentiate between clicking on a check box (to check/uncheck a node) versus a label (to select a node).

The latter example also has code for recursively toggling subtrees in response to boxes being checked or unchecked (see the treeNodesChanged method).

See also this question on StackOverflow.