Package-level declarations

Types

Link copied to clipboard
sealed interface BorderPanelScope : PanelScope

The receiver of the content of a Panel under PanelLayout.Border, through which a child declares which region of that panel it occupies.

Link copied to clipboard
sealed interface CardPanelScope : PanelScope

The receiver of the content of a Panel under PanelLayout.Card, through which a child names the card it is placed on.

Link copied to clipboard
sealed interface GridBagPanelScope : PanelScope

The receiver of the content of a Panel under PanelLayout.GridBag, through which a child declares the cell it occupies.

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

Link copied to clipboard
interface PanelScope

The receiver of the content of a container a PanelLayout lays out. Each PanelLayout names the scope it hands its children, through which they declare their own placement under that layout; a layout that places children by declaration order alone hands this one, which offers nothing.

Link copied to clipboard
sealed interface ScrollPaneScope

The receiver of a ScrollPane's content, through which a child declares the part of the pane it configures or the region it fills.

Link copied to clipboard
sealed interface ScrollScope

The receiver of a ScrollState.scroll block, through which the block moves the pane.

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 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 PanelLayout.Box panel 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 Panel(modifier: SwingModifier = SwingModifier, content: @Composable PanelScope.() -> Unit)

A JPanel under the layout a JPanel builds itself with: a PanelLayout.Flow laying content out in a centered row that wraps, 5 apart in user-space coordinates.

@Composable
fun <S : PanelScope> Panel(layout: PanelLayout<S>, modifier: SwingModifier = SwingModifier, content: @Composable S.() -> Unit)

A JPanel under the Swing layout manager layout names, holding content as its children.

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 - the rigid area of Box.createRigidArea.

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, its scroll bars, and the headers and corners that stay put beside them declared as content.

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

Empty space of a fixed size, 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 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.