[External] : Re: Convenience factories for Border and Background

Kevin Rushforth kevin.rushforth at oracle.com
Thu May 13 16:08:56 UTC 2021


No, I don't like this option at all. This would just duplicate a lot of 
API methods that would end up delegating to Color. And it would be much 
worse to duplicate the color constants. This just doesn't seem like a 
clean API approach.

-- Kevin

On 5/13/2021 8:41 AM, Michael Strauß wrote:
> 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