On Tue, 20 Jan 2026 19:25:42 GMT, Andy Goryachev <[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.

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.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/2015#issuecomment-3775047169

Reply via email to