On Tue, 20 Jan 2026 21:32:23 GMT, John Hendrikx <[email protected]> wrote:
>>> JavaFX already has this concept today, but we're not using the `Property`
>>> API to model it. Layout constraints like `GridPane.columnIndex` or
>>> `HBox.margin` are implemented as static getter/setter pairs. Since they are
>>> not first-class properties, you don't get any of the nice property features
>>> (bindings, listeners, styling, etc).
>>
>> I always found this design to be weird and unnecessary - these should be the
>> properties/constraints of the container or the layout, not something stored
>> in the child nodes. What happens when the said child is moved from one
>> container to another??
>>
>> It might be just me, but I fail to see the value of this proposal.
>
>> > JavaFX already has this concept today, but we're not using the `Property`
>> > API to model it. Layout constraints like `GridPane.columnIndex` or
>> > `HBox.margin` are implemented as static getter/setter pairs. Since they
>> > are not first-class properties, you don't get any of the nice property
>> > features (bindings, listeners, styling, etc).
>>
>> I always found this design to be weird and unnecessary - these should be the
>> properties/constraints of the container or the layout, not something stored
>> in the child nodes. What happens when the said child is moved from one
>> container to another??
>>
>> It might be just me, but I fail to see the value of this proposal.
>
> This is basically the JavaFX way to attach layout information to nodes, used
> by `GridPane`, `HBox`, `StackPane`, etc. In Swing this is handled
> differently by making layout constraints a 2nd parameter when adding a node
> (like `GridBagConstraints`), in FX this is done via the general `Properties`
> map which is much more flexible. Extending this system so they become full,
> observable properties, and even styleable properties is a very logical step.
> Making them styleable for example will allow you to move them to CSS:
>
>
> .button {
> -fx-hbox-margin: 10 10 10 10;
> -fx-hbox-hgrow: ALWAYS;
> }
>
> This is currently one of the biggest missing features when it comes to
> styling controls, having to go to programmatic configuration for these kinds
> of styling properties.
Thank you @hjohn this example makes sense.
So, if I understand it correctly, the proposal is to add two-tiered styleable
properties? Are there limitations as to which attached property is legal for
which node, or any attached property (including custom) can be attached to any
node? I understand that CSS part is not there yet, but perhaps this PR should
instead go via `HasAttachedProperties` route?
-------------
PR Comment: https://git.openjdk.org/jfx/pull/2015#issuecomment-3775125620