actionListener

Runs onAction on the action event of a component that fires one - the same components actionListener lists.

onAction is read when the event fires, so writing a fresh lambda on every recomposition registers nothing again.

Return

this chain with the action callback declared on it.

Parameters

onAction

receives the event, whose actionCommand is the command string the component was given, falling back to a button's text or a text field's contents.

See also


inline fun <T : Component> SwingModifier.actionListener(noinline onAction: T.(ActionEvent) -> Unit): SwingModifier

Runs onAction on the action event of a component of type T that fires one, with that component as this.

Return

this chain with the action callback declared on it.

Parameters

onAction

read when the event fires. A parameter of the enclosing composable shadows the receiver, so reach it through this. Read the component's state through the receiver; writing a property the composition declares through it makes the second manager listener describes.

See also


Runs onAction on the action event of a component of type targetType that fires one, with that component as this. An event sourced anywhere else is refused; see listener.

Return

this chain with the action callback declared on it.

Parameters

targetType

the component type the node and every event's source are both checked against.

onAction

read when the event fires.

See also


Attaches an ActionListener (addActionListener/removeActionListener) to a component that fires action events (AbstractButton - so JButton, JCheckBox, ... -, JTextField, JComboBox, JFileChooser, and the AWT Button, TextField, and List).

A text field fires its action event when the user presses Enter in it, which is what the interaction family's onAccept reports. That has a registration of its own, narrowed to JTextField, so declaring both attaches two listeners rather than moving one.

Return

this chain with the action listener declared on it.

Parameters

listener

attached by identity, so a remembered instance stays put while a fresh one on every pass is detached and re-added.

See also