CheckBox

@Composable
fun CheckBox(text: @Nls String, checked: Boolean, onCheckedChange: (Boolean) -> Unit, modifier: SwingModifier = SwingModifier)

A JCheckBox, a labeled box the user turns on and off. The box shows whatever checked holds, and every toggle the user makes is reported through onCheckedChange. Boxes are independent of one another, so any number of them can be checked at once.

A toggle the caller does not answer with a matching checked does not stand: the box is back on the declared state before the toggle is painted.

Parameters

text

the text to display next to the checkbox

checked

the checked state the box is held at

onCheckedChange

callback invoked with the checked state when the box is activated

modifier

the SwingModifier applied to the underlying component

See also


@Composable
fun CheckBox(text: @Nls String, checked: Boolean, actionListener: ActionListener, modifier: SwingModifier = SwingModifier)

A CheckBox driven by a raw ActionListener instead of an onCheckedChange lambda. The actionListener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn.

Parameters

text

the text to display next to the checkbox

checked

the checked state the box is held at

actionListener

the listener notified when the checkbox is toggled

modifier

the SwingModifier applied to the underlying component

See also