Package-level declarations

Types

Link copied to clipboard
@Immutable
object Alignment

Where a child sits across the axis its container arranges children along: an Alignment.Horizontal positions a child across a Column, an Alignment.Vertical across a Row.

Link copied to clipboard
@Immutable
object Arrangement

How a Row or Column places its children along the axis it arranges them on, and how much space it leaves between two adjacent children.

Link copied to clipboard
sealed interface BorderPanelScope

The receiver of a BorderPanel's content, through which a child declares which region of that panel it occupies.

Link copied to clipboard
sealed interface CardPanelScope

The receiver of a CardPanel's content, through which a child names the card it is placed on.

Link copied to clipboard
sealed interface ColumnScope

The receiver of a Column's content, through which a child declares its own placement in that column.

Link copied to clipboard
sealed interface GridBagPanelScope

The receiver of a GridBagPanel's content, through which a child declares the cell it occupies.

Link copied to clipboard
annotation class LayoutScopeMarker

Marks the scope a layout hands its content, so that only the innermost one is in reach.

Link copied to clipboard
sealed interface RowScope

The receiver of a Row's content, through which a child declares its own placement in that row.

Link copied to clipboard
sealed interface ScrollPaneScope

The receiver of a ScrollPane's content, through which a child declares the region of the pane it is installed in.

Link copied to clipboard
@Stable
class ScrollState

A hoistable state holder for the scroll position of a ScrollPane.

Link copied to clipboard
sealed interface SplitPaneScope

The receiver of a SplitPane's content, through which a child declares which of the two sides it occupies.

Link copied to clipboard
sealed interface TabbedPaneScope

The receiver of a TabbedPane's content, through which a child declares the tab it is the page of.

Functions

Link copied to clipboard
@Composable
fun BorderPanel(modifier: SwingModifier = SwingModifier, hgap: Int = 0, vgap: Int = 0, content: @Composable BorderPanelScope.() -> Unit)

A JPanel under a BorderLayout, placing 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
@Composable
fun BoxPanel(modifier: SwingModifier = SwingModifier, axis: Int = BoxLayout.Y_AXIS, content: @Composable () -> Unit = {})

A JPanel under a BoxLayout: the children are laid out one after another along a single axis, in declaration order.

Link copied to clipboard
@Composable
fun CardPanel(selectedCard: String, modifier: SwingModifier = SwingModifier, hgap: Int = 0, vgap: Int = 0, content: @Composable CardPanelScope.() -> Unit)

A JPanel under a CardLayout: 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
@Composable
fun Column(modifier: SwingModifier = SwingModifier, verticalArrangement: Arrangement.Vertical = Arrangement.Top, horizontalAlignment: Alignment.Horizontal = Alignment.Start, content: @Composable ColumnScope.() -> Unit)

A composable that arranges its content vertically, top to bottom.

Link copied to clipboard
@Composable
fun FlowPanel(modifier: SwingModifier = SwingModifier, alignment: Int = FlowLayout.CENTER, hgap: Int = 5, vgap: Int = 5, content: @Composable () -> Unit = {})

A JPanel under a FlowLayout: the children are laid out in a row, each at the size it prefers, and a child that no longer fits the panel's width starts a new row.

Link copied to clipboard
@Composable
fun Glue(modifier: SwingModifier = SwingModifier, orientation: Int? = null)

Empty space that asks for nothing and grows without bound - the glue of Box.createGlue, Box.createHorizontalGlue and Box.createVerticalGlue. A BoxPanel or a ToolBar shares the extent it has left over among its children in proportion to the room each has between its preferred and its maximum size; glue prefers nothing and has no ceiling, so its share is the largest. That share is the whole of the leftover extent where every sibling's maximum size is the size it prefers, and a part of it alongside any sibling with room to grow - room a component has until a maximum size is set on it:

Link copied to clipboard
@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.

Link copied to clipboard
@Composable
fun GridPanel(modifier: SwingModifier = SwingModifier, rows: Int = 1, cols: Int = 0, hgap: Int = 0, vgap: Int = 0, content: @Composable () -> Unit = {})

A JPanel under a GridLayout: the panel is divided into equally sized cells and the children fill them one per cell, row by row in the panel's reading order.

Link copied to clipboard
@Composable
fun rememberScrollState(x: Int = 0, y: Int = 0): ScrollState

Creates and remembers a ScrollState starting at x, y.

Link copied to clipboard
@Composable
fun RigidArea(width: Int, height: Int, modifier: SwingModifier = SwingModifier)

Empty space of a fixed size, width by height pixels - the rigid area of Box.createRigidArea.

Link copied to clipboard
@Composable
fun Row(modifier: SwingModifier = SwingModifier, horizontalArrangement: Arrangement.Horizontal = Arrangement.Start, verticalAlignment: Alignment.Vertical = Alignment.Top, content: @Composable RowScope.() -> Unit)

A composable that arranges its content horizontally, along the panel's reading order.

Link copied to clipboard
@Composable
fun ScrollPane(modifier: SwingModifier = SwingModifier, state: ScrollState = rememberScrollState(), verticalScrollbar: Int = JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, horizontalScrollbar: Int = JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED, viewportBorder: Border? = null, wheelScrollingEnabled: Boolean = true, content: @Composable ScrollPaneScope.() -> Unit)

A scrolling view onto content larger than the room it has - a JScrollPane, with the viewport it scrolls and the headers and corners that stay put beside it declared as content.

Link copied to clipboard
@Composable
fun Spacer(size: Int, modifier: SwingModifier = SwingModifier)

Empty space of a fixed size pixels, on both axes alike - a convenience over RigidArea with one size for both.

Link copied to clipboard
@Composable
fun SplitPane(dividerLocationListener: PropertyChangeListener, modifier: SwingModifier = SwingModifier, orientation: Int = JSplitPane.HORIZONTAL_SPLIT, dividerLocation: Int = -1, resizeWeight: Double = 0.0, oneTouchExpandable: Boolean? = null, dividerSize: Int? = null, continuousLayout: Boolean? = null, content: @Composable SplitPaneScope.() -> Unit)

A SplitPane driven by a raw PropertyChangeListener instead of an onDividerLocationChange lambda. The listener is attached for the dividerLocation property as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn. Attached as-is, it hears every dividerLocation change the pane publishes, including the pane's own writes and, for a negative (default) dividerLocation, the position that request resolves to once realized on screen - old=-1 new=<resolved> - indistinguishable from a user's move.

@Composable
fun SplitPane(modifier: SwingModifier = SwingModifier, orientation: Int = JSplitPane.HORIZONTAL_SPLIT, dividerLocation: Int = -1, onDividerLocationChange: (Int) -> Unit = {}, resizeWeight: Double = 0.0, oneTouchExpandable: Boolean? = null, dividerSize: Int? = null, continuousLayout: Boolean? = null, content: @Composable SplitPaneScope.() -> Unit)

Two sides of one area, split by a divider the user drags to give one side room at the other's expense

Link copied to clipboard
@Composable
fun Strut(orientation: Int, size: Int, modifier: SwingModifier = SwingModifier)

Empty space that holds size pixels along orientation and reaches for as much as it is offered across it - the strut of Box.createHorizontalStrut and Box.createVerticalStrut. A horizontal strut holds a width and takes whatever height it is given, a vertical one holds a height and takes whatever width.

Link copied to clipboard
@Composable
fun TabbedPane(selectedIndex: Int, changeListener: ChangeListener, modifier: SwingModifier = SwingModifier, tabPlacement: Int = JTabbedPane.TOP, tabLayoutPolicy: Int = JTabbedPane.WRAP_TAB_LAYOUT, content: @Composable TabbedPaneScope.() -> Unit)

A TabbedPane driven by a raw ChangeListener instead of an onSelectedIndexChange lambda. The listener is notified of the tab the user selects, and of the tab the pane is left on where selectedIndex names no tab of the strip, reading the new selection off the event's source pane; the latest declared instance is the one notified, so the listener may be declared inline.

@Composable
fun TabbedPane(selectedIndex: Int, onSelectedIndexChange: (Int) -> Unit, modifier: SwingModifier = SwingModifier, tabPlacement: Int = JTabbedPane.TOP, tabLayoutPolicy: Int = JTabbedPane.WRAP_TAB_LAYOUT, content: @Composable TabbedPaneScope.() -> Unit)

A stack of pages of which one shows at a time, picked from a strip of tabs - a JTabbedPane. The pane holds which tab is selected and reports the tab the user clicks.

Link copied to clipboard
@Composable
fun ToolBar(modifier: SwingModifier = SwingModifier, orientation: Int = SwingConstants.HORIZONTAL, floatable: Boolean? = null, floating: Boolean = false, onFloatingChange: (Boolean) -> Unit = {}, rollover: Boolean? = null, content: @Composable () -> Unit = {})

A strip of items - buttons, toggles, separators - the user reaches without opening a menu, held by a JToolBar. The bar holds whether it stands docked or in a window of its own, and reports the drags that move it between the two.

Link copied to clipboard
@Composable
fun ToolBarSeparator(modifier: SwingModifier = SwingModifier, size: Dimension? = null)

The divider that groups a ToolBar's items - JToolBar.Separator. It takes its orientation from the bar holding it, so it lies across the bar's own axis and turns with it. To divide anything else, use org.jetbrains.compose.swing.components.Separator.