GridBagPanel

@Composable
fun GridBagPanel(modifier: SwingModifier = SwingModifier, content: @Composable GridBagPanelScope.() -> Unit)

A JPanel under a GridBagLayout, placing each child in the grid cell that child's own constraints describe - the row and column it starts at, the cells it spans, its share of the leftover extent, and how it fills the cell it is given.

A child names its cell with item, through GridBagPanelScope:

GridBagPanel {
Label(text = "Name", modifier = SwingModifier.item(gridx = 0, gridy = 0))
Button(
text = "Pick",
onClick = ::pick,
modifier = SwingModifier.item(gridx = 1, gridy = 0, weightx = 1.0, fill = GridBagConstraints.HORIZONTAL),
)
}

A child that declares no item is laid out under GridBagConstraints' own defaults.

Constraints are reactive: changing a child's arguments re-places it, and dropping the child (e.g. behind an if) removes it.

Parameters

modifier

the SwingModifier applied to the panel

content

the composable content of the panel; see GridBagPanelScope

See also