RadioButtonMenuItem

@Composable
fun RadioButtonMenuItem(text: @Nls String, selected: Boolean, onSelectedChange: (Boolean) -> Unit, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

A menu item carrying a radio mark: a JRadioButtonMenuItem that shows selected and reports the user's activation through onSelectedChange. The item stands on its own, so activating it toggles the mark; for a set of items where at most one is marked, use RadioButtonMenuGroup.

A change the caller does not answer with a matching selected 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

selected

whether the menu item is selected

onSelectedChange

callback invoked with the selected 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 RadioButtonMenuItem(text: @Nls String, selected: Boolean, actionListener: ActionListener, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

A JRadioButtonMenuItem driven by a raw ActionListener instead of an onSelectedChange 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

selected

whether the menu item is selected

actionListener

the listener notified 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