- java.lang.Object
-
- javafx.scene.layout.Border
-
public final class Border extends Object
The Border of aRegion. A Border is an immutable object which encapsulates the entire set of data required to render the border of a Region. Because this class is immutable, you can freely reuse the same Border on many different Regions. Please refer to JavaFX CSS Reference Guide for a complete description of the CSS rules for styling the border of a Region.Every Border is comprised of
strokesand / orimages. Neither list will ever be null, 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 theinsetsandoutsetsof the Border.The Border's
outsetsdefine any extension of the drawing area of a Region which is necessary to account for all border drawing and positioning. These outsets are defined by both theBorderStrokes andBorderImages specified on this Border. Outsets are strictly non-negative.getInsets()are used to define the inner-most edge of all of the borders. It also is always strictly non-negative. The Region uses the insets of theBackgroundand Border and theRegion's paddingto determine the Regioninsets, which define the content area for any children of the Region. The outsets of a Border together with the outsets of a Background and the width and height of the Region define the geometric bounds of the Region (which in turn contribute to thelayoutBounds,boundsInLocal, andboundsInParent).A Border is most often used in cases where you want to skin the Region 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Indicates whether some other object is "equal to" this one.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.InsetsgetInsets()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.InsetsgetOutsets()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.inthashCode()Returns a hash code value for the object.booleanisEmpty()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 thestrokesoroutsetsorinsets.- 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 theimagesoroutsetsorinsets.- 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 thestrokesorimages,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 thestrokesorimages,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 specifiedstrokesare not drawn. If this list is null or no images succeeded in loading, then any specifiedstrokesare 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 outsets 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.
-
equals
public boolean equals(Object o)
Indicates whether some other object is "equal to" this one.The
equalsmethod implements an equivalence relation on non-null object references:- It is reflexive: for any non-null reference value
x,x.equals(x)should returntrue. - It is symmetric: for any non-null reference values
xandy,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any non-null reference values
x,y, andz, ifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue. - It is consistent: for any non-null reference values
xandy, multiple invocations ofx.equals(y)consistently returntrueor consistently returnfalse, provided no information used inequalscomparisons on the objects is modified. - For any non-null reference value
x,x.equals(null)should returnfalse.
The
equalsmethod for classObjectimplements the most discriminating possible equivalence relation on objects; that is, for any non-null reference valuesxandy, this method returnstrueif and only ifxandyrefer to the same object (x == yhas the valuetrue).Note that it is generally necessary to override the
hashCodemethod whenever this method is overridden, so as to maintain the general contract for thehashCodemethod, which states that equal objects must have equal hash codes.- Overrides:
equalsin classObject- Parameters:
o- the reference object with which to compare.- Returns:
trueif this object is the same as the obj argument;falseotherwise.- See Also:
Object.hashCode(),HashMap
- It is reflexive: for any non-null reference value
-
hashCode
public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided byHashMap.The general contract of
hashCodeis:- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
hashCodemethod must consistently return the same integer, provided no information used inequalscomparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. - If two objects are equal according to the
equals(Object)method, then calling thehashCodemethod on each of the two objects must produce the same integer result. - It is not required that if two objects are unequal
according to the
Object.equals(java.lang.Object)method, then calling thehashCodemethod on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by class
Objectdoes return distinct integers for distinct objects. (The hashCode may or may not be implemented as some function of an object's memory address at some point in time.)- Overrides:
hashCodein classObject- Returns:
- a hash code value for this object.
- See Also:
Object.equals(java.lang.Object),System.identityHashCode(java.lang.Object)
- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
-
-