Package org.gnome.gtk

Class CheckButton

java.lang.Object
All Implemented Interfaces:
Proxy, Accessible, Actionable, Buildable, ConstraintTarget

@Generated("io.github.jwharm.JavaGI") public class CheckButton extends Widget implements Accessible, Actionable, Buildable, ConstraintTarget
A GtkCheckButton places a label next to an indicator.

Example GtkCheckButtons

A GtkCheckButton is created by calling either CheckButton() or withLabel(java.lang.String).

The state of a GtkCheckButton can be set specifically using setActive(boolean), and retrieved using getActive().

Inconsistent state
In addition to "on" and "off", check buttons can be an "in between" state that is neither on nor off. This can be used e.g. when the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a check button, and the current values in that range are inconsistent.

To set a GtkCheckButton to inconsistent state, use setInconsistent(boolean).

Grouping
Check buttons can be grouped together, to form mutually exclusive groups - only one of the buttons can be toggled at a time, and toggling another one will switch the currently toggled one off.

Grouped check buttons use a different indicator, and are commonly referred to as *radio buttons*.

Example GtkCheckButtons

To add a GtkCheckButton to a group, use setGroup(org.gnome.gtk.CheckButton).

When the code must keep track of the state of a group of radio buttons, it is recommended to keep track of such state through a stateful GAction with a target for each button. Using the toggled signals to keep track of the group changes and state is discouraged.

Shortcuts and Gestures
GtkCheckButton supports the following keyboard shortcuts:

  • or Enter activates the button.

CSS nodes


 checkbutton[.text-button][.grouped]
 ├── check
 ╰── [label]
 

A GtkCheckButton has a main node with name checkbutton. If the Gtk.CheckButton:label or Gtk.CheckButton:child properties are set, it contains a child widget. The indicator node is named check when no group is set, and radio if the checkbutton is grouped together with other checkbuttons.

Accessibility
GtkCheckButton uses the AccessibleRole.CHECKBOX role.