Summary
Add convenience methods for creating simple Backgrounds and Borders.
Problem
Creating simple Backgrounds and Borders is cumbersome as they require a verbose constructor invocation compared to what is requested from the user.
Solution
Add convenience factory methods for the simple cases.
Specification
Added to Background:
/**
* A convenience factory method for creating a {@code Background} with a single {@code Paint}.
*
* @implSpec
* This call is equivalent to {@link BackgroundFill#BackgroundFill(Paint, CornerRadii, Insets)
* new Background(new BackgroundFill(fill, null, null));}.
* @param fill the fill of the background. If {@code null}, {@code Color.TRANSPARENT} will be used.
* @return a new background of the given fill
* @since 18
*/
public static Background fill(Paint fill) {
return new Background(new BackgroundFill(fill, null, null));
}
Added to Border:
/**
* A convenience factory method for creating a solid {@code Border} with a single {@code Paint}.
*
* @implSpec
* This call is equivalent to {@link BorderStroke#BorderStroke(Paint, BorderStrokeStyle, CornerRadii, BorderWidths)
* new Border(new BorderStroke(stroke, BorderStrokeStyle.SOLID, null, null));}.
* @param stroke the stroke of the border (for all sides). If {@code null}, {@code Color.BLACK} will be used.
* @return a new border of the given stroke
* @since 18
*/
public static Border stroke(Paint stroke) {
return new Border(new BorderStroke(stroke, BorderStrokeStyle.SOLID, null, null));
}
- csr of
-
JDK-8272870 Add convenience factory methods for Border and Background
-
- Resolved
-