layoutConstraint

Places the component in its parent container under constraint - the value Container.add(Component, Object) takes: a BorderLayout region name, a GridBagConstraints, a CardLayout card name, or whatever the enclosing container's layout manager understands.

The placement follows the value: change it and the component moves within the same parent, keeping its position among its siblings. It reaches the node whose modifier declares it and travels no further, so a container placed this way lays its own children out under the constraints each of them declares. The last constraint declared in a modifier chain wins, and a modifier declaring none leaves the component placed by index alone.

The placement is re-applied whenever the declared value does not compare equal to the one applied last, so a constraint compared by identity - as a raw GridBagConstraints is - re-registers the component on every pass that rebuilds it. A constraint compared by value holds still when rebuilt from the same declaration, which is what the scope builders - org.jetbrains.compose.swing.components.layout.GridBagPanelScope.item among them - supply.

The value is handed over the way Container.add(Component, Object) hands it over: a LayoutManager2 receives it as-is and reports a value it does not understand with its own exception, while a manager that takes no constraints places the component by index.

Return

this modifier with the placement declared on it.

Parameters

constraint

the placement the parent container's layout manager registers the component under.

See also