Package-level declarations

Types

Link copied to clipboard

The scope of a style for any component; every component's own style scope extends it. A style runs when the component is applied, never in composition. A snapshot state it reads runs it again when that state changes.

Link copied to clipboard

What a style can do on a container: set Component and JComponent properties and provide nested styles to the components below it. SwingModifier.styleable { ... } without a SwingStyleKind gives this scope, so it is the way to style a composable that does not take a style parameter.

Link copied to clipboard

Identifies the styles an ancestor provides for descendants of one kind. Identity is the instance.

Link copied to clipboard

The scope of a component that holds children, which may provide a nested style that a styleable descendant component reads and applies.

Link copied to clipboard

The properties of a JComponent. A third-party JComponent builds its own scope on this one, or on a narrower one, so every setter declared here works in its style too.

Link copied to clipboard
fun interface SwingStyle<in S : SwingStyleScope>

A style: a block over the scope S, semantically like a lambda executed on S. A property the style sets is written onto the component, and a property it stops setting gets back the value the component held before the style wrote it.

Link copied to clipboard

How a component kind is styled: how its scope is built and what its default style does. Declare one per component kind, as a top-level val. A style of this kind runs against the scope S, which the kind builds over the state T the component feeds it, Unit for a kind without state.

Link copied to clipboard
annotation class SwingStyleMarker

A DslMarker used to ensure that a member of an outer style scope does not resolve inside a nested block. Applied to every style scope.

Link copied to clipboard

Defines a style property whose value can be provided within a style scope. Its type names only the value; the component it applies to is checked when the style is applied.

Link copied to clipboard
interface SwingStyleScope

The base interface for all style scopes, and the receiver of every style.

Properties

Link copied to clipboard

Styles for every descendant in the same composition, including descendants without a style declaration. A style provided for the descendant's kind takes precedence, regardless of how far away each provider is.

Functions

Link copied to clipboard

Sets the component's accessible description - a longer localized explanation assistive technologies can read after the name. null clears any description this style set.

Link copied to clipboard

Sets the component's accessible name - the short localized string assistive technologies announce for it. null clears any name this style set. Mirrors AndroidX's semantics { contentDescription = ... }.

Link copied to clipboard

Sets the horizontal alignment along the x axis, where 0.0 aligns to the left, 0.5 centers, and 1.0 aligns to the right. A parent that honors alignment - a vertical BoxLayout - lines its children up by this value, so siblings given the same alignment stay in one column.

Link copied to clipboard

Sets the vertical alignment along the y axis, where 0.0 aligns to the top, 0.5 centers, and 1.0 aligns to the bottom. A parent that honors alignment - a horizontal BoxLayout - lines its children up by this value, so siblings given the same alignment stay on one row.

Link copied to clipboard
inline fun <S : SwingStyleScope> S.apply(style: SwingStyle<S>)

Runs style at this point of the enclosing style, as if its block were written here: a property this style sets after the call wins over style's value, and style's value wins over one set before the call.

Link copied to clipboard

Sets background; on a non-opaque component also set opaque to true for it to paint.

Link copied to clipboard

Sets the component's border. null removes it.

Link copied to clipboard
fun ComponentStyleScope.bounds(x: Int, y: Int, width: Int, height: Int)

Sets the component's bounds - its position and size within its parent. Effective in a parent that does not lay its children out (a null layout, or a LayeredPane), where each child positions itself.

Link copied to clipboard

Sets componentOrientation - the component's left-to-right / right-to-left orientation.

Link copied to clipboard

Sets cursor; null restores the inherited cursor.

Link copied to clipboard

Sets an invisible border occupying insets. See emptyBorder (the four-side form).

Sets an invisible border of all on every side. See emptyBorder (the four-side form).

fun SwingComponentStyleScope.emptyBorder(top: Int, left: Int, bottom: Int, right: Int)

Sets an invisible border with the specified space on each side. margin is the space a button or text component keeps inside its border. See border for precedence and restoration.

Link copied to clipboard

Sets isEnabled on this component only, controlling whether it responds to user input and paints in its enabled state. To disable descendants, use provideNestedStyle(AllComponents) { enabled(false) } on a container. The provided style does not disable the container itself, and a descendant's own enabled(true) overrides it.

Link copied to clipboard

Sets isFocusable, declaring whether this component can receive keyboard focus.

Link copied to clipboard

Sets font; null takes the font from the parent container.

Link copied to clipboard

Sets foreground; null takes the color from the parent container.

Link copied to clipboard

Sets the component's actual height to height, keeping its current width, like setSize(width, height). See size (the Int overload) for when this takes effect and how size/width/height compose.

Link copied to clipboard
fun SwingComponentStyleScope.lineBorder(color: Color, thickness: Int = 1)

Sets a line border in color, thickness thick. See border for precedence and restoration.

Link copied to clipboard

Sets the component's actual location to point, like setLocation. See location (the Int overload) for how it takes effect only outside a managed layout and how location/x/y compose per axis.

Sets the component's actual location to (x, y) relative to its parent, like setLocation. A layout manager overrides this on its next layout pass, so it takes effect for components positioned by themselves - those in a null layout or a JLayeredPane.

Link copied to clipboard

Sets maximumSize and relays out; null restores the layout-computed maximum size.

fun ComponentStyleScope.maximumSize(width: Int, height: Int)

Sets maximumSize to Dimension(width, height) and relays out.

Link copied to clipboard

Sets minimumSize and relays out; null restores the layout-computed minimum size.

fun ComponentStyleScope.minimumSize(width: Int, height: Int)

Sets minimumSize to Dimension(width, height) and relays out.

Link copied to clipboard
fun <S : ComponentStyleScope, T> nestingStyleKind(scope: (base: NestedStyleProviderScope, state: T) -> S, default: SwingStyle<S>): SwingStyleKind<S, T>

A kind whose default only applies nested styles, such as applyNestedStyle(key). With no style of its own and no publishing ancestor, a component of this kind runs no default and holds no style resolution.

Link copied to clipboard

Sets isOpaque - required for background to actually paint.

Link copied to clipboard

Sets preferredSize and relays out; null restores the layout-computed preferred size.

Sets preferredSize to Dimension(width, height) and relays out.

Link copied to clipboard

Sets the component's actual size to size, like setSize. See size (the Int overload) for when this takes effect and how size/width/height compose.

fun ComponentStyleScope.size(width: Int, height: Int)

Sets the component's actual size to width by height, like setSize. A layout manager overrides this on its next layout pass, so it takes effect for components positioned by themselves - those in a null layout or a JLayeredPane. To influence a managed layout, use preferredSize, minimumSize, or maximumSize instead.

Link copied to clipboard

Declares style as the component's style. The style can set every java.awt.Component and JComponent property and provide nested styles to the components below. Put it last in the modifier.

Applies kind's default style followed by style to this component.

Link copied to clipboard
fun <V> styleLocalOf(descriptor: ComponentPropertyDescriptor<*, V>, restores: RestorePolicy = RestorePolicy.EverythingWritten, rewriteOn: String? = null, alsoOverwrites: List<ComponentPropertyDescriptor<*, *>> = emptyList()): SwingStyleProperty<V>

Local style properties inherit their values down the component hierarchy. As stylePropertyOf, for a property a descendant inherits: a styled descendant that sets no value takes the value of the nearest styled ancestor that set one, where descriptor handles the descendant's class. An ancestor that sets null stops the inheritance; its descendants keep their own value. This holds for a nullable style local, since a non-null one such as componentOrientation cannot be set to null. Locals with the same descriptor name share one property; the last declaration wins for the component and its descendants.

Link copied to clipboard

Creates a style property whose value is applied by a custom element. A declaration replaces an earlier one with the same key. The element's equality, target constraints and restoration behavior apply as in a modifier. A style writes its descriptor-backed properties before its custom elements. Each group follows declaration order.

fun <V> stylePropertyOf(descriptor: ComponentPropertyDescriptor<*, V>, restores: RestorePolicy = RestorePolicy.EverythingWritten, rewriteOn: String? = null, alsoOverwrites: List<ComponentPropertyDescriptor<*, *>> = emptyList()): SwingStyleProperty<V>

Creates a style property with the restore and rewrite options of SwingModifier.property. A style property and a modifier property with the same descriptor name share the original value to restore.

Link copied to clipboard
fun <S : SwingStyleScope> SwingStyle(vararg styles: SwingStyle<S>): SwingStyle<S>

Combines styles into one style that runs them in order, so where several set a property, the last one's value wins. As then, empty styles are skipped and combinations with equal styles in the same order are equal.

Link copied to clipboard

Combines this style with other. other runs after this style, so where both set a property, other's value wins.

Link copied to clipboard
fun SwingComponentStyleScope.toolTip(text: (event: MouseEvent) -> @Nls String?)

Sets the tooltip for the pointer's location. text returns null where no tooltip is available.

Sets the tooltip for the whole component. null clears it.

Link copied to clipboard

Whether the inputVerifier of the component that currently holds the keyboard is consulted before focus moves to this component. Swing's own value is true; set false on a control that must act regardless of what the focused field holds, such as a Cancel button or a scrollbar.

Link copied to clipboard

Sets isVisible - whether the component is shown in its parent's layout.

Link copied to clipboard

Sets the component's actual width to width, keeping its current height, like setSize(width, height). See size (the Int overload) for when this takes effect and how size/width/height compose.

Link copied to clipboard

Sets the component's actual x position to value, keeping its current y, like setLocation(x, y). See location (the Int overload) for how it takes effect only outside a managed layout and how location/x/y compose per axis.

Link copied to clipboard

Sets the component's actual y position to value, keeping its current x, like setLocation(x, y). See location (the Int overload) for how it takes effect only outside a managed layout and how location/x/y compose per axis.