property
Declares descriptor on the component, value for as long as this declaration stands. A style declares a property through org.jetbrains.compose.swing.style.stylePropertyOf or org.jetbrains.compose.swing.style.styleLocalOf, with the same rules. 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.
Build descriptor once, as a top-level val, with ComponentPropertyDescriptor's constructors:
private val DividerSizeProperty =
ComponentPropertyDescriptor<JSplitPane, Int>(
name = "dividerSize",
read = { it.dividerSize },
write = { pane, v -> pane.dividerSize = v },
)
private fun SwingModifier.declaredDividerSize(dividerSize: Int?): SwingModifier =
if (dividerSize == null) this else property(DividerSizeProperty, dividerSize)Use this function for a component's own parameter that no style setter covers. Two declarations of one ComponentPropertyDescriptor.name - even through two different handles - share one slot: the last one declared wins, and they take one record of what the property stood at before either wrote it, put back from whichever of them leaves last. Every handle of one name has to read and write the property alike.
Return
this modifier with descriptor declared on it.
Parameters
the property being written.
the value to write while this declaration stands.
what the component is held to once this declaration leaves. RestorePolicy.EverythingWritten, the default, holds it to carrying descriptor's read answer again. RestorePolicy.DeclaredPropertyOnly holds it to descriptor's name alone, for a write a look and feel derives a property of its own from. RestorePolicy.None is for a property the component offers no way to give back - one whose setter refuses the value read answered with, or rebuilds the component's UI - and descriptor's own write says what the component keeps instead.
names a bean property whose announced change means value may have been overwritten, so the node listens for it and writes value again. Name the property itself where the component announces every change of it, its own write included. Reassertion happens only after a matching PropertyChangeEvent; a component or look and feel that mutates it silently cannot be observed or reasserted. Outside writes by declarations with rewriteOn, all matching declarations reapply their values. During such a write and any nested writes, only declarations applied after the latest rewriteOn declaration that wrote may reapply their values. The writing declaration and earlier declarations ignore these events, so synchronous notifications cannot repeat the same write. A later declaration of the same property that does not name rewriteOn does not win over this one.
properties descriptor's own write lands on besides the one it declares - a coarse geometry naming each axis it covers, a button's fill keeping its opaque flag in step with it. Each is held beside the declared one and given back after it, so a removal puts back every property the write touched, not only the one this declaration names.
Deprecated
Provide a nested style: style = { provideNestedStyle(AllComponents) { ... } }.
Declares descriptor as property does, optionally providing it to descendants as a component default.
Return
this modifier with descriptor declared on it.
Parameters
the property being written.
the value to write while this declaration stands.
what the component is held to once this declaration leaves.
lets the declaration be provided to descendants as a component default - a property such as a color or a font that makes sense across a whole subtree. A property descriptor serves only some component types reaches only those among the descendants.
the bean property whose announced change makes the node write value again.
properties descriptor's own write lands on besides the one it declares.