PanelLayout

@Immutable
abstract class PanelLayout<S : PanelScope>(val contentScope: S)

The layout of a container the composition lays out: the Swing layout manager the container holds, the parameters that manager takes, and the scope S through which the container's children declare their placement under it.

A Panel lays its JPanel out through three pieces, and any node's container is laid out through the same three: update = { layout.installOn(this) }, contentScope as the content's receiver, and key(layout.javaClass) around the content, since the constraints the children carry belong to the manager that was there. The node itself is not keyed: installOn changes the manager's kind in place.

A layout not modeled here is declared by subclassing this class, with installOn writing through installManager, or held by a container of your own whose children place themselves with SwingModifier.layoutConstraint - see docs/CUSTOM-CONTAINERS.md for both. A subclass is immutable, holding its parameters in vals, and its equals compares them: a layout equal to the one before writes nothing.

Inheritors

Constructors

Link copied to clipboard
constructor(contentScope: S)

Types

Link copied to clipboard
class Border(val hgap: Int = 0, val vgap: Int = 0) : PanelLayout<BorderPanelScope>

Places each child in the region that child names: the four edges and the center. An edge child keeps the thickness it prefers and spans its edge, and the center child takes whatever the edges leave.

Link copied to clipboard
class Box(val axis: Int = BoxLayout.Y_AXIS) : PanelLayout<PanelScope>

Lays the children out one after another along a single axis, in declaration order.

Link copied to clipboard
class Card(val selectedCard: String, val hgap: Int = 0, val vgap: Int = 0) : PanelLayout<CardPanelScope>

Holds the children as a deck of cards of which exactly one is shown. The deck asks for room enough for its largest card, so showing another card does not resize it.

Link copied to clipboard
class Flow(val alignment: Int = FlowLayout.CENTER, val hgap: Int = 5, val vgap: Int = 5) : PanelLayout<PanelScope>

Lays the children out in a row, each at the size it prefers, and starts a new row with the child that no longer fits the panel's width.

Link copied to clipboard
class Grid(val rows: Int = 1, val cols: Int = 0, val hgap: Int = 0, val vgap: Int = 0) : PanelLayout<PanelScope>

Divides the panel into equally sized cells and fills them with the children, one per cell, row by row in the panel's reading order.

Link copied to clipboard

Places 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.

Properties

Link copied to clipboard

the scope the container's content is composed in

Functions

Link copied to clipboard
abstract fun <C : Container> installOn(updater: SwingNodeUpdater<C>)

Lays the container out under this layout. An implementation makes one write on updater through installManager.