RFR: 8272870: Add convenience factory methods for border and background [v2]

Nir Lisker nlisker at openjdk.java.net
Thu Sep 9 23:00:04 UTC 2021


On Fri, 3 Sep 2021 21:08:27 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/javafx/scene/layout/Background.java line 366:
>> 
>>> 364:      */
>>> 365:     public static Background fill(Paint fill) {
>>> 366:         return new Background(new BackgroundFill(fill, null, null));
>> 
>> null **CornerRaddii** and null **Insets** will use **CornerRadii.EMPTY** and **Insets.EMPTY**. Maybe we should use those here instead so it's more clear for anyone having a look in the source code? I also always use those instead of null.
>> Same for **BorderStroke**
>
> Are you talking about the implementation or the code? I guess both, since the `@implSepc` indicates what this call is equivalent to. I don't have a strong opinion on this one.

You don't need to look at the source code, I can link to the delegated constructor and the docs will show those. I prefer using `null`s because the point of these is that you want a border/background with 1 color and you don't care about things like widths, insets and corners - they default to whatever the default is. If you care what they are, this method is probably not what you're looking for. It's also shorter and less to read through when the extra info is defaults.

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

PR: https://git.openjdk.java.net/jfx/pull/610


More information about the openjfx-dev mailing list