Button

@Composable
fun Button(text: @Nls String, onClick: () -> Unit, modifier: SwingModifier = SwingModifier)

A JButton push button labeled text, which calls onClick each time the button is activated. Activation is an event and nothing more: the button carries no value for the caller to hold.

Parameters

text

the text to display on the button

onClick

callback to be invoked when the button is clicked

modifier

the SwingModifier applied to the underlying component

See also


@Composable
fun Button(text: @Nls String, actionListener: ActionListener, modifier: SwingModifier = SwingModifier)

A Button driven by a raw ActionListener instead of an onClick lambda.

The actionListener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid a detach/re-attach on every recomposition.

Parameters

text

the text to display on the button

actionListener

the listener notified when the button is activated

modifier

the SwingModifier applied to the underlying component

See also