Convenience factories for Border and Background

Michael Strauß michaelstrau2 at gmail.com
Thu May 13 15:41:41 UTC 2021


Another option could be to mirror the `Color` API in both `Border` and
`Background`, like in the following examples:

Color.rgb(125, 100, 75)
Border.rgb(125, 100, 75)
Background.rgb(125, 100, 75)

Color.gray(127)
Border.gray(127)
Background.gray(127)

Color.web("orange", 0.5)
Border.web("orange", 0.5)
Background.web("orange", 0.5)

We could also mirror the named color constants, which would enable a
very compact syntax:

StackPane pane = new StackPane();
pane.setBorder(Border.RED);
pane.setBackground(Background.BLUE);

This is very similar to how "red" or "blue" are valid values for
"-fx-border" or "-fx-background" in CSS.


More information about the openjfx-dev mailing list