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

Nir Lisker nlisker at gmail.com
Wed Sep 29 12:42:04 UTC 2021


Then the PR is ready for a final review. I'll create the CSR shortly.

On Wed, Sep 29, 2021 at 3:07 PM Kevin Rushforth <kevin.rushforth at oracle.com>
wrote:

> Absent a strong motivation for adding this, I recommend to go with the
> current proposal, which does not include this newly requested method. It
> can always be added later if there is a compelling need.
>
> -- Kevin
>
> On 9/24/2021 4:50 AM, Nir Lisker wrote:
>
> I don't have a strong opinion on this addition.
>
> On Fri, Sep 24, 2021 at 2:47 PM Kevin Rushforth <
> kevin.rushforth at oracle.com> wrote:
>
>> I don't have an objection to adding this one additional convenience
>> method if it is generally useful. If there aren't a lot of applications
>> that would use it, it seems better to go with just the two identified so
>> far and consider this one later.
>>
>> So: would this be a generally useful addition?
>>
>> -- Kevin
>>
>>
>> On 9/21/2021 2:43 AM, Marius Hanl wrote:
>> >     As also written in a comment
>> >     here: https://github.com/openjdk/jfx/pull/610
>> <https://urldefense.com/v3/__https://github.com/openjdk/jfx/pull/610__;!!ACWV5N9M2RV99hQ!Z57Y3Q7VQc4ZpD__IA299Q56jo8wF4MJh1J9wWOm6uFYnJfouoapPE0p9pPWIry9Tyav$>
>> >     I would like to propose one more convenience method which should be
>> >     added to JavaFX:
>> >
>> > public static Border stroke(Paint stroke, double width) {
>> >      return new Border(new BorderStroke(stroke,
>> BorderStrokeStyle.SOLID, null, ne
>> > w BorderWidths(width)));
>> > }
>> >
>> >     I think it's quite common that you want to create a solid border
>> with
>> >     another width then the default of 1 (for every side).
>> >
>> >     Note: This is also the last use case I think makes sense to add as a
>> >     convenience method.
>> >     Any other use case is likely to be so complex that it makes sense to
>> >     use the normal existing constructors.
>> >
>> >     Feel free to share you opinion.
>> >
>> >     - Marius
>> >
>> >     Gesendet: Dienstag, 08. Juni 2021 um 03:19 Uhr
>> >     Von: "Nir Lisker" <nlisker at gmail.com>
>> >     An: "Kevin Rushforth" <kevin.rushforth at oracle.com>
>> >     Cc: "openjfx-dev at openjdk.java.net Mailing"
>> >     <openjfx-dev at openjdk.java.net>
>> >     Betreff: Re: [External] : Re: Convenience factories for Border and
>> >     Background
>> >     The new API:
>> >     1. `Border.of(Paint stroke)` or `Border.stroke(Paint stroke)` that
>> does
>> >     `new Border(new BorderStroke(Paint stroke , BorderStrokeStyle.SOLID,
>> >     null,
>> >     null));`
>> >     2. `Background.of((Paint fill)` or `Background.fill(Paint fill)`
>> that
>> >     does
>> >     `new Background(new BackgroundFill(Paint fill, null, null));`
>> >     I don't mind either name choice.
>> >     On Tue, Jun 8, 2021 at 2:50 AM Kevin Rushforth
>> >     <kevin.rushforth at oracle.com>
>> >     wrote:
>> >     > If I recall, there were a few developers that chimed in. It's a
>> >     simple
>> >     > enough addition -- at least your original proposal (not the
>> >     suggestion of
>> >     > mirroring the Color API, which I don't like) -- that it seems OK
>> to
>> >     me.
>> >     >
>> >     > Can you repost your currently proposed API and see if those who
>> might
>> >     like
>> >     > to use it are satisfied with it?
>> >     >
>> >     > -- Kevin
>> >     >
>> >     >
>> >     > On 6/7/2021 4:41 PM, Nir Lisker wrote:
>> >     >
>> >     > Does this constitute sufficient interest in the enhancement?
>> >     >
>> >     > On Thu, May 13, 2021 at 6:41 PM Michael Strau�
>> >     <michaelstrau2 at gmail.com>
>> >     > 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