Card

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.

Each child names the card it is placed on through CardPanelScope, and selectedCard picks the card the deck shows:

Panel(PanelLayout.Card(selectedCard = page)) {
Label(text = "Welcome", modifier = SwingModifier.card("welcome"))
Label(text = "Details", modifier = SwingModifier.card("details"))
}

A card holds a single child; two children naming the same card are reported as an error on the event dispatch thread once the change pass that caused it has settled, so a pass that replaces a card's occupant need not take the outgoing child out before the incoming one arrives. The report reaches whatever handles an uncaught exception on that thread - by default the JDK's, which prints it and moves on, so an application that installs none of its own keeps running with both children on the card.

Dropping a child (e.g. behind an if) takes its card with it, and a selectedCard matching no card leaves the card currently on top showing. A child that names no card is placed on the deck's empty-named card, which an empty selectedCard shows; that card holds a single child like any other, so two children naming none are refused the way a card named twice is.

See also

Constructors

Link copied to clipboard
constructor(selectedCard: String, hgap: Int = 0, vgap: Int = 0)

Properties

Link copied to clipboard

the scope the container's content is composed in

Link copied to clipboard
val hgap: Int

the horizontal gap between the panel's left/right edges and the shown card; 0 by default, so the card reaches those edges

Link copied to clipboard

the key of the card to show

Link copied to clipboard
val vgap: Int

the vertical gap between the panel's top/bottom edges and the shown card; 0 by default, so the card reaches those edges

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun <C : Container> installOn(updater: SwingNodeUpdater<C>)

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