CheckBoxMenuItem

@Composable
fun CheckBoxMenuItem(text: @Nls String, checked: Boolean, onCheckedChange: (Boolean) -> Unit, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

A menu item carrying a checkmark: a JCheckBoxMenuItem that shows checked and reports the user's toggle through onCheckedChange.

A toggle the caller does not answer with a matching checked is settled back onto the declared value, so the mark on screen is the one the composition holds.

Parameters

text

the text of the menu item

checked

whether the item shows its checkmark

onCheckedChange

callback invoked with the checked state when the item is activated

modifier

the SwingModifier applied to the underlying component

accelerator

the key combination that activates the item without navigating the menu hierarchy, displayed next to its text; null (the default) leaves the item without one

See also


@Composable
fun CheckBoxMenuItem(text: @Nls String, checked: Boolean, actionListener: ActionListener, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

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

Parameters

text

the text of the menu item

checked

whether the menu item is checked

actionListener

the listener notified when the item is toggled

modifier

the SwingModifier applied to the underlying component

accelerator

the key combination that activates the item without navigating the menu hierarchy, displayed next to its text; null (the default) leaves the item without one

See also