- java.lang.Object
-
- javafx.scene.layout.Border
-
public final class Border extends Object
The border of aRegion
. ABorder
is an immutable object which encapsulates the entire set of data required to render the border of aRegion
. Because this class is immutable, you can freely reuse the sameBorder
on many differentRegion
s. Please refer to JavaFX CSS Reference Guide for a complete description of the CSS rules for styling the border of aRegion
.Every
Border
is comprised ofstrokes
and / orimages
. Neither list will ever benull
, but either or both may be empty. When rendering, if no images are specified or no image succeeds in loading, then all strokes will be rendered in order. If any image is specified and succeeds in loading, then no strokes will be drawn, although they will still contribute to theinsets
andoutsets
of theBorder
.The
Border
'soutsets
define any extension of the drawing area of aRegion
which is necessary to account for all border drawing and positioning. Theseoutsets
are defined by both theBorderStroke
s andBorderImage
s specified on thisBorder
.outsets
are strictly non-negative.insets
are used to define the inner-most edge of all of the borders. It also is always strictly non-negative. TheRegion
uses the insets of theBackground
andBorder
, and theRegion's padding
to determine theRegion
insets
, which define the content area for any children of theRegion
. Theoutsets
of aBorder
together with theoutsets
of aBackground
, and the width and height of theRegion
define the geometric bounds of theRegion
(which in turn contribute to thelayoutBounds
,boundsInLocal
, andboundsInParent
).A
Border
is most often used in cases where you want to skin theRegion
with an image, often used in conjunction with 9-patch scaling techniques. In such cases, you may also specify a stroked border which is only used when the image fails to load for some reason.- Since:
- JavaFX 8.0
-
-
Constructor Summary
Constructors Constructor Description Border(List<BorderStroke> strokes, List<BorderImage> images)
Creates a new Border by supplying a List of BorderStrokes and BorderImages.Border(BorderImage... images)
Creates a new Border by supplying an array of BorderImages.Border(BorderStroke... strokes)
Creates a new Border by supplying an array of BorderStrokes.Border(BorderStroke[] strokes, BorderImage[] images)
Creates a new Border by supplying an array of BorderStrokes and BorderImages.
-
Method Summary
Modifier and Type Method Description boolean
equals(Object o)
static List<CssMetaData<? extends Styleable,?>>
getClassCssMetaData()
List<BorderImage>
getImages()
The list of BorderImages which together define the images to use instead of stroke for this Border.Insets
getInsets()
The insets define the distance from the edge of the Region to the inner-most edge of the border, if that distance is non-negative.Insets
getOutsets()
The outsets of the border define the outer-most edge of the border to be drawn.List<BorderStroke>
getStrokes()
The list of BorderStrokes which together define the stroked portion of this Border.int
hashCode()
boolean
isEmpty()
Gets whether the Border is empty.
-
-
-
Field Detail
-
EMPTY
public static final Border EMPTY
An empty Border, useful to use instead of null.
-
-
Constructor Detail
-
Border
public Border(BorderStroke... strokes)
Creates a new Border by supplying an array of BorderStrokes. This array may be null, or may contain null values. Any null values will be ignored and will not contribute to thestrokes
oroutsets
orinsets
.- Parameters:
strokes
- The strokes. This may be null, and may contain nulls. Any contained nulls are filtered out and not included in the final List of strokes. A null array becomes an empty List. If both strokes and images are specified, and if any one of the images specified succeeds in loading, then no strokes are shown. In this way, strokes can be defined as a fallback in the case that an image failed to load.
-
Border
public Border(BorderImage... images)
Creates a new Border by supplying an array of BorderImages. This array may be null, or may contain null values. Any null values will be ignored and will not contribute to theimages
oroutsets
orinsets
.- Parameters:
images
- The images. This may be null, and may contain nulls. Any contained nulls are filtered out and not included in the final List of images. A null array becomes an empty List.
-
Border
public Border(List<BorderStroke> strokes, List<BorderImage> images)
Creates a new Border by supplying a List of BorderStrokes and BorderImages. These Lists may be null, or may contain null values. Any null values will be ignored and will not contribute to thestrokes
orimages
,outsets
, orinsets
.- Parameters:
strokes
- The strokes. This may be null, and may contain nulls. Any contained nulls are filtered out and not included in the final List of strokes. A null array becomes an empty List. If both strokes and images are specified, and if any one of the images specified succeeds in loading, then no strokes are shown. In this way, strokes can be defined as a fallback in the case that an image failed to load.images
- The images. This may be null, and may contain nulls. Any contained nulls are filtered out and not included in the final List of images. A null array becomes an empty List.
-
Border
public Border(BorderStroke[] strokes, BorderImage[] images)
Creates a new Border by supplying an array of BorderStrokes and BorderImages. These arrays may be null, or may contain null values. Any null values will be ignored and will not contribute to thestrokes
orimages
,outsets
, orinsets
.- Parameters:
strokes
- The strokes. This may be null, and may contain nulls. Any contained nulls are filtered out and not included in the final List of strokes. A null array becomes an empty List. If both strokes and images are specified, and if any one of the images specified succeeds in loading, then no strokes are shown. In this way, strokes can be defined as a fallback in the case that an image failed to load.images
- The images. This may be null, and may contain nulls. Any contained nulls are filtered out and not included in the final List of images. A null array becomes an empty List.
-
-
Method Detail
-
getClassCssMetaData
public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
- Returns:
- The CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
-
getStrokes
public final List<BorderStroke> getStrokes()
The list of BorderStrokes which together define the stroked portion of this Border. This List is unmodifiable and immutable. It will never be null. It will never contain any null elements.- Returns:
- the list of BorderStrokes which together define the stroked portion of this Border
-
getImages
public final List<BorderImage> getImages()
The list of BorderImages which together define the images to use instead of stroke for this Border. If this list is specified and at least one image within it succeeds in loading, then any specifiedstrokes
are not drawn. If this list is null or no images succeeded in loading, then any specifiedstrokes
are drawn.This List is unmodifiable and immutable. It will never be null. It will never contain any null elements.
- Returns:
- the list of BorderImages which together define the images to use instead of stroke for this Border
-
getOutsets
public final Insets getOutsets()
The outsets of the border define the outer-most edge of the border to be drawn. The values in these outsets are strictly non-negative.- Returns:
- the outsets of the border define the outer-most edge of the border to be drawn
-
getInsets
public final Insets getInsets()
The insets define the distance from the edge of the Region to the inner-most edge of the border, if that distance is non-negative. The values in these insets are strictly non-negative.- Returns:
- the insets define the distance from the edge of the Region to the inner-most edge of the border
-
isEmpty
public final boolean isEmpty()
Gets whether the Border is empty. It is empty if there are no strokes or images.- Returns:
- true if the Border is empty, false otherwise.
-
-