componentListener

Runs onComponentChange whenever the component is resized, moved, shown or hidden. Declare the four separately to tell them apart.

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

Return

this chain with the component callback declared on it.

Parameters

onComponentChange

receives the event, whose id tells the four apart.

See also


fun SwingModifier.componentListener(onComponentResized: (ComponentEvent) -> Unit = UNDECLARED, onComponentMoved: (ComponentEvent) -> Unit = UNDECLARED, onComponentShown: (ComponentEvent) -> Unit = UNDECLARED, onComponentHidden: (ComponentEvent) -> Unit = UNDECLARED): SwingModifier

Runs each lambda on the change it is declared for. A change left undeclared reports nowhere.

Each lambda is read when its event fires, so writing a fresh one on every recomposition registers nothing again.

Declaring none at all is refused.

Return

this chain with the component callbacks declared on it.

Parameters

onComponentResized

runs after the size changed, so the component already reports the new one.

onComponentMoved

runs after the position changed, which is stated in the parent's coordinates.

onComponentShown

runs when the component itself is made visible; a parent being shown does not reach it.

onComponentHidden

runs when the component itself is made invisible.

See also


Attaches a ComponentListener (addComponentListener/removeComponentListener).

Return

this chain with the component 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