treeWillExpandListener

Asks onWillChange before a node of the tree opens or closes whether it may: answering false leaves the node as it was and no expansion event follows. Requires a javax.swing.JTree target.

Return

this chain with the veto callback declared on it.

Parameters

onWillChange

answers for the node the event's path names; it is read when the event fires, so a fresh lambda on every recomposition registers nothing again.

See also


fun SwingModifier.treeWillExpandListener(onWillExpand: (TreeExpansionEvent) -> Boolean = UNDECLARED_ANSWER, onWillCollapse: (TreeExpansionEvent) -> Boolean = UNDECLARED_ANSWER): SwingModifier

Asks onWillExpand before a node opens, and onWillCollapse before one closes, whether the change may happen: answering false leaves the node as it was and no expansion event follows. Requires a javax.swing.JTree target. A direction left undeclared allows the change.

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 veto callbacks declared on it.

Parameters

onWillExpand

answers before the node opens; false reaches the tree as the veto that keeps it closed.

onWillCollapse

answers before the node closes; false reaches the tree as the veto that keeps it open.

See also


Attaches a TreeWillExpandListener (addTreeWillExpandListener/removeTreeWillExpandListener), notified before a node opens or closes. Requires a javax.swing.JTree target.

The listener answers a change it refuses with a javax.swing.tree.ExpandVetoException, which is what a JTree reads as a veto: the node is left as it was and no expansion event follows.

Return

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