Package-level declarations

Types

Link copied to clipboard
class ComponentPropertyDescriptor<in T : Component, V>(val name: String, targetType: Class<out Component>, read: (component: T) -> V, write: (component: T, value: V) -> Unit, handles: (componentClass: Class<*>) -> Boolean)

One Swing property of one or more component types. Define it once, in a top-level val, and declare it on a component with SwingModifier.property; see that function for the full contract.

Link copied to clipboard

A component that is handed the modifier nodes it carries, in the order its modifier declares them - what a component that paints or lays out through its nodes implements.

Link copied to clipboard

What a modifier element puts back when its declaration leaves, declared through SwingModifier.NodeElement.restores.

Link copied to clipboard
@Stable
interface SwingModifier

An ordered, immutable collection of Elements applied to a Swing component - the Swing analogue of androidx.compose.ui.Modifier. Most are a NodeElement, which carries the node that writes onto the component; the rest declare something the node holder reads itself, such as where the component is attached in its parent.

Link copied to clipboard

The diff state for one node's modifier: the elements applied last, and the buffers the modifier being applied is partitioned into.

Functions

Link copied to clipboard

Declares a modifier built by calling composables. factory runs in the composition of each component the modifier reaches, before the modifier is applied, and what it returns is applied in place of this entry, so a remember inside it keeps one value per component.

Link copied to clipboard
fun SwingModifier.key(vararg keys: Any?): SwingModifier

Ties this modifier's application to keys. While they stand the modifier is diffed as usual; a key that does not compare equal to the one applied last rebuilds from scratch what the modifier writes onto the component.

Link copied to clipboard
fun <T : Component, V> SwingModifier.property(descriptor: ComponentPropertyDescriptor<T, V>, value: V, restores: RestorePolicy = RestorePolicy.EverythingWritten, inheritable: Boolean = false, rewriteOn: String? = null, alsoOverwrites: List<ComponentPropertyDescriptor<T, *>> = emptyList()): SwingModifier

Declares descriptor on the component, value for as long as this declaration stands. The property is read as the declaration arrives and written back when the declaration leaves, so a widget that outlives it carries what it did before.