IntelliJ Platform Plugin SDK Help

Checkbox

A preview of checkboxes in different states

When to use

Use checkboxes for yes/no choices or for selecting several items in a group:

An example of a checkbox group with two selected options

When not to use

If only one option in a group can be selected, use radio button:

Incorrect

A radio button group with only one selected option possible

Correct

Two radio buttons with clear labels

If the behavior in the "off" state is unclear from the checkbox label, use two radio buttons instead and label them accordingly:

Incorrect

A radio button group with only one selected option possible

Correct

Two radio buttons with clear labels

How to use

Label on the right

A label accompanies each checkbox and is placed on the right side.

Correct

A correct checkbox with the label on the right

Incorrect

An incorrect checkbox with the label on the left

Long labels

If a label is long, split it into two lines. Use HTML formatting for that. Avoid labels that take more than two lines. See recommendations on writing concise labels below.

Correct

A correct checkbox with the label on the right

Incorrect

An incorrect checkbox with the label on the left

Implementation

checkBox( """<html>Insert selected suggestion by pressing space, dot,<br/> or other context-dependent keys</html>""")
new JCheckBox( "<html>Insert selected suggestion by pressing space, dot,<br/>" + "or other context-dependent keys</html>");

Checkboxes in a table

If a checkbox appears in a table, place the label into the column header and do not repeat it on every row:

A table with checkboxes where the label is placed into the column header

Implementation

Checkboxes are rendered in tables with BooleanTableCellRenderer and edited with DefaultCellEditor(JCheckBox) implementation. For any column that should be rendered as a checkbox, set both a renderer and editor for consistency. The type of data in the correspondent column of the Table model should either be Boolean or String containing true or false.

TableColumn column = table.getColumnModel().getColumn(COLUMN_INDEX); column.setCellEditor(JBTable.createBooleanEditor()); column.setCellRenderer(new BooleanTableCellRender());

Three-state checkbox

Status of children

In a group of options, use the parent checkbox to show the status of its children. The state of the parent checkbox can be checked, indeterminate or unchecked. When a user clicks an indeterminate checkbox for the first time, the whole group becomes checked. The second click unchecks the whole group.

Different states for a parent checkbox: checked, indeterminate, and unchecked
Implementation

The three-state checkbox is represented by the ThreeStateCheckBox class which represents its state with the ThreeStateCheckBox.State enum containing SELECTED, NOT_SELECTED, DONT_CARE states.

Download status

An indeterminate checkbox can also show the download status. In the example below, a remote repository with Repositories "tools-base" and "contrib" are being loaded. When loading is finished, the indeterminate checkbox will be replaced with the checked checkbox if there are commits, or an unchecked checkbox if there are no commits.

Indeterminate checkboxes showing download status
Implementation

In a table, the three-state checkbox is represented by ThreeStateCheckBoxRenderer that provides both TableCellRenderer and TableEditor. It accepts Boolean type in the column being supplied by the TableModel and becomes DONT_CARE when the value in the cell is null. Otherwise, it becomes SELECTED for Boolean.TRUE, and NOT_SELECTED for Boolean.FALSE.

Writing guidelines

Use sentence-style capitalization:

Correct

A correct checkbox with the imperative form of the verb

Incorrect

An incorrect checkbox with the declarative form of the verb

Do not use ending punctuation:

Correct

A correct checkbox with the imperative form of the verb

Incorrect

An incorrect checkbox with the declarative form of the verb

Use the imperative form of verbs:

Correct

A correct checkbox with the imperative form of the verb

Incorrect

An incorrect checkbox with the declarative form of the verb

Do not use negation in labels as it complicates understanding:

Correct

A correct checkbox with the imperative form of the verb

Incorrect

An incorrect checkbox with the declarative form of the verb

Make labels short and intelligible. See Writing short and clear.

How to layout

Follow the guidelines for checkboxes and radio buttons layout.

Last modified: 23 January 2025