MenuItem

@Composable
fun MenuItem(text: @Nls String, onClick: () -> Unit, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

An item that performs an action when the user picks it: a JMenuItem reporting the pick through onClick.

Parameters

text

the text of the menu item

onClick

callback to be invoked when the menu item is clicked

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 MenuItem(text: @Nls String, actionListener: ActionListener, modifier: SwingModifier = SwingModifier, accelerator: KeyStroke? = null)

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

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