Class BorderStroke
- All Implemented Interfaces:
Interpolatable<BorderStroke>
public final class BorderStroke extends Object implements Interpolatable<BorderStroke>
Border for styling a Region. The stroke is a vector-based rendering that outlines the border area. It can be inset (or outset) from the Region's edge, and the values of the stroke are taken into account when computing the Region's insets (for defining the content area). The stroke visuals are not used when any BorderImages are in use. When applied to a Region with a defined shape, the border width and stroking information for the top is used, while the other attributes are ignored.
- Since:
- JavaFX 8.0
Field Summary
| Modifier and Type | Field | Description |
|---|---|---|
static final BorderWidths |
DEFAULT_WIDTHS |
The default Insets to be used with a BorderStroke that does not otherwise define any. |
static final BorderWidths |
MEDIUM |
The default insets when "medium" is specified |
static final BorderWidths |
THICK |
The default insets when "thick" is specified |
static final BorderWidths |
THIN |
The default insets when "thin" is specified. |
Constructor Summary
| Constructor | Description |
|---|---|
BorderStroke |
Creates a new BorderStroke. |
BorderStroke |
Creates a new BorderStroke. |
BorderStroke |
Creates a new BorderStroke, specifying all construction parameters. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
final Paint |
getBottomStroke() |
Defines the fill of bottom side of this border. |
final BorderStrokeStyle |
getBottomStyle() |
Defines the style of bottom side of this border. |
final Insets |
getInsets() |
Defines the insets of each side of the BorderStroke. |
final Paint |
getLeftStroke() |
Defines the fill of left side of this border. |
final BorderStrokeStyle |
getLeftStyle() |
Defines the style of left side of this border. |
final CornerRadii |
getRadii() |
Defines the radii for each corner of this BorderStroke. |
final Paint |
getRightStroke() |
Defines the fill of right side of this border. |
final BorderStrokeStyle |
getRightStyle() |
Defines the style of right side of this border. |
final Paint |
getTopStroke() |
Defines the fill of top side of this border. |
final BorderStrokeStyle |
getTopStyle() |
Defines the style of top side of this border. |
final BorderWidths |
getWidths() |
Defines the thickness of each side of the BorderStroke. |
BorderStroke |
interpolate |
Returns an intermediate value between the value of this Interpolatable and the specified endValue using the linear interpolation factor t, ranging from 0 (inclusive) to 1 (inclusive). |
final boolean |
isStrokeUniform() |
Checks if the stroke of this region is uniform. |
Field Details
THIN
public static final BorderWidths THIN
MEDIUM
public static final BorderWidths MEDIUM
THICK
public static final BorderWidths THICK
DEFAULT_WIDTHS
public static final BorderWidths DEFAULT_WIDTHS
Constructor Details
BorderStroke
public BorderStroke(Paint stroke, BorderStrokeStyle style, CornerRadii radii, BorderWidths widths)
BorderStroke.- Parameters:
-
stroke- The stroke to use for all sides. Ifnull, defaults toColor.BLACK. -
style- The style to use for all sides. Ifnull, defaults toBorderStrokeStyle.NONE. -
radii- The radii to use. Ifnull, defaults toCornerRadii.EMPTY. -
widths- The widths to use. Ifnull, defaults toDEFAULT_WIDTHS.
BorderStroke
public BorderStroke(Paint stroke, BorderStrokeStyle style, CornerRadii radii, BorderWidths widths, Insets insets)
BorderStroke.- Parameters:
-
stroke- The stroke to use for all sides. Ifnull, defaults toColor.BLACK. -
style- The style to use for all sides. Ifnull, defaults toBorderStrokeStyle.NONE. -
radii- The radii to use. Ifnull, defaults toCornerRadii.EMPTY. -
widths- The widths to use. Ifnull, defaults toDEFAULT_WIDTHS. -
insets- The insets indicating where to draw the border relative to the region edges. Ifnull, defaults toInsets.EMPTY.
BorderStroke
public BorderStroke(Paint topStroke, Paint rightStroke, Paint bottomStroke, Paint leftStroke, BorderStrokeStyle topStyle, BorderStrokeStyle rightStyle, BorderStrokeStyle bottomStyle, BorderStrokeStyle leftStyle, CornerRadii radii, BorderWidths widths, Insets insets)
BorderStroke, specifying all construction parameters.- Parameters:
-
topStroke- The fill to use on the top. Ifnull, defaults toColor.BLACK. -
rightStroke- The fill to use on the right. Ifnull, defaults to the same value astopStroke. -
bottomStroke- The fill to use on the bottom. Ifnull, defaults to the same value astopStroke. -
leftStroke- The fill to use on the left. Ifnull, defaults to the same value asrightStroke. -
topStyle- The style to use on the top. Ifnull, defaults toBorderStrokeStyle.NONE. -
rightStyle- The style to use on the right. Ifnull, defaults to the same value astopStyle. -
bottomStyle- The style to use on the bottom. Ifnull, defaults to the same value astopStyle. -
leftStyle- The style to use on the left. Ifnull, defaults to the same value asrightStyle. -
radii- The radii. Ifnull, defaults to square corners by usingCornerRadii.EMPTY. -
widths- The thickness of each side. Ifnull, defaults toDEFAULT_WIDTHS. -
insets- The insets indicating where to draw the border relative to the region edges. Ifnull, defaults toInsets.EMPTY.
Method Details
getTopStroke
public final Paint getTopStroke()
- Default value:
Color.BLACK- Interpolation Type:
- see
Paint - Returns:
- the fill of top side of this border
getRightStroke
public final Paint getRightStroke()
null, then the topFill is used.- Default value:
-
null(same astopFill) - Interpolation Type:
- see
Paint - Returns:
- the fill of right side of this border
getBottomStroke
public final Paint getBottomStroke()
null, then the topFill is used.- Default value:
-
null(same astopFill) - Interpolation Type:
- see
Paint - Returns:
- the fill of bottom side of this border
getLeftStroke
public final Paint getLeftStroke()
null, then the rightFill is used.- Default value:
-
null(same asrightFill) - Interpolation Type:
- see
Paint - Returns:
- the fill of left side of this border
getTopStyle
public final BorderStrokeStyle getTopStyle()
- Default value:
BorderStrokeStyle.NONE- Interpolation Type:
- discrete
- Returns:
- the style of top side of this border
getRightStyle
public final BorderStrokeStyle getRightStyle()
null, then topStyle is used;- Default value:
-
null(same astopStyle) - Interpolation Type:
- discrete
- Returns:
- the style of right side of this border
getBottomStyle
public final BorderStrokeStyle getBottomStyle()
null, then topStyle is used; Use BorderStyle.NONE to set the border to have no border style.- Default value:
-
null(same astopStyle) - Interpolation Type:
- discrete
- Returns:
- the style of bottom side of this border
getLeftStyle
public final BorderStrokeStyle getLeftStyle()
null, then rightStyle is used. Use BorderStyle.NONE to set the border to have no border style.- Default value:
-
null(same asrightStyle) - Interpolation Type:
- discrete
- Returns:
- the style of left side of this border
getWidths
public final BorderWidths getWidths()
BorderStroke. This will never be null, and defaults to DEFAULT_WIDTHS.- Interpolation Type:
- default
- Returns:
- the thickness of each side of the
BorderStroke
getInsets
public final Insets getInsets()
BorderStroke. This will never be null, and defaults to Insets.EMPTY.- Interpolation Type:
- default
- Returns:
- the insets of each side of the
BorderStroke
getRadii
public final CornerRadii getRadii()
BorderStroke. This will never be null, and defaults to CornerRadii.EMPTY.- Interpolation Type:
- default
- Returns:
- the radii for each corner of this
BorderStroke
isStrokeUniform
public final boolean isStrokeUniform()
- Returns:
-
trueif border stroke is uniform
interpolate
public BorderStroke interpolate(BorderStroke endValue, double t)
Interpolatable and the specified endValue using the linear interpolation factor t, ranging from 0 (inclusive) to 1 (inclusive). The returned value might not be a new instance; the implementation might also return one of the two existing instances if the intermediate value would be equal to one of the existing values. However, this is an optimization and applications should not assume any particular identity of the returned value.
- Specified by:
-
interpolatein interfaceInterpolatable<BorderStroke> - Parameters:
-
endValue- the target value -
t- the interpolation factor - Returns:
- the intermediate value
- Throws:
-
NullPointerException- ifendValueisnull - Since:
- 24
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.