Top Description Inners Fields Constructors Methods
org.controlsfx.tools

public final Class Borders

extends Object
Class Inheritance
Imports
javafx.geometry.Insets, javafx.scene.Node, javafx.scene.control.Label, javafx.scene.layout.*, javafx.scene.paint.Color, javax.swing.*, java.util.ArrayList, .Arrays, .List

A utility class that allows you to wrap JavaFX Nodes with a border, in a way somewhat analogous to the Swing BorderFactory (although with less options as a lot of what the Swing BorderFactory offers resulted in ugly borders!).

The Borders class provides a fluent API for specifying the properties of each border. It is possible to create multiple borders around a Node simply by continuing to call additional methods before you call the final Borders#build() method. To use the Borders class, you simply call Borders#wrap(Node), passing in the Node you wish to wrap the border(s) around.

Examples

Firstly, lets wrap a JavaFX Button node with a simple line border that looks like the following:

Screenshot of Borders.LineBorders

Here's the code:

Button button = new Button("Hello World!");
Node wrappedButton = Borders.wrap(button).lineBorder().buildAll();

Easy, isn't it!? You can make the border look a little nicer by replacing the line border with an etched border. An etched border has a subtle inner (or outer) line that makes the border stand out a bit more, like this:

Screenshot of Borders.EtchedBorders

Now that's one good looking border! Here's the code:

Button button = new Button("Hello World!");
Node wrappedButton = Borders.wrap(button).etchedBorder().buildAll();

In some circumstances you want to have multiple borders. For example, you might two line borders. That's easy:

Screenshot of two Borders.LineBorders
Node wrappedButton = Borders.wrap(button)
    .lineBorder().color(Color.RED).build()
    .lineBorder().color(Color.GREEN).build()
    .build();

You simply chain the borders together, going from inside to outside!

Because of all the configuration options it isn't possible to list all the functionality of all the border types, so refer to the rest of the javadocs for inspiration.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Borders.Border

The public interface used by the Borders API to wrap nodes with zero or more Border implementations.

public class
Borders.EmptyBorders

A fluent API that is only indirectly instantiable via the Borders fluent API, and which allows for an empty border to be wrapped around a given Node.

public class
Borders.EtchedBorders

A fluent API that is only indirectly instantiable via the Borders fluent API, and which allows for an etched border to be wrapped around a given Node.

public class
Borders.LineBorders

A fluent API that is only indirectly instantiable via the Borders fluent API, and which allows for a line border to be wrapped around a given Node.

private static class
Borders.StrokeBorder

Private support classes

Field Summary

Modifier and TypeField and Description
private final List<Borders.Border>
private static final Color
DEFAULT_BORDER_COLOR

Static fields

private final Node
node

Internal fields

Constructor Summary

AccessConstructor and Description
private
Borders(Node n)

Private Constructor

Method Summary

Modifier and TypeMethod and Description
public Borders
addBorder(Borders.Border border)

Allows for developers to develop custom Border implementations, and to wrap them around a Node.

public Node
build()

Returns the original node wrapped in zero or more borders, as specified using the fluent API.

public Borders.EmptyBorders
emptyBorder()

Often times it is useful to have a bit of whitespace around a Node, to separate it from what it is next to.

public Borders.EtchedBorders
etchedBorder()

The etched border look is essentially equivalent to the lineBorder() look, except rather than one line, there are two.

public Borders.LineBorders
lineBorder()

Creates a nice, simple border around the node.

public static Borders
wrap(Node n)

Fluent API entry method(s)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bordersback to summary
private final List<Borders.Border> borders
DEFAULT_BORDER_COLORback to summary
private static final Color DEFAULT_BORDER_COLOR

Static fields

nodeback to summary
private final Node node

Internal fields

Constructor Detail

Bordersback to summary
private Borders(Node n)

Private Constructor

Method Detail

addBorderback to summary
public Borders addBorder(Borders.Border border)

Allows for developers to develop custom Border implementations, and to wrap them around a Node. Note that of course this is mostly redundant (as you could just call Border#wrap(Node) directly). The only benefit is if you're creating a compound border consisting of multiple borders, and you want your custom border included as part of this.

buildback to summary
public Node build()

Returns the original node wrapped in zero or more borders, as specified using the fluent API.

emptyBorderback to summary
public Borders.EmptyBorders emptyBorder()

Often times it is useful to have a bit of whitespace around a Node, to separate it from what it is next to. Call this method to begin building a border that will wrap the node with a given amount of whitespace (which can vary between the top, right, bottom, and left sides).

etchedBorderback to summary
public Borders.EtchedBorders etchedBorder()

The etched border look is essentially equivalent to the lineBorder() look, except rather than one line, there are two. What is commonly done in this circumstance is that one of the lines is a very light colour (commonly white), which gives a nice etched look. Refer to the API in EtchedBorders for more information.

lineBorderback to summary
public Borders.LineBorders lineBorder()

Creates a nice, simple border around the node. Note that there are many configuration options in LineBorders, so explore it carefully.

wrapback to summary
public static Borders wrap(Node n)

Fluent API entry method(s)

org.controlsfx.tools back to summary

public Interface Borders.Border

Known Direct Implementers
org.controlsfx.tools.Borders.StrokeBorder
Annotations
@FunctionalInterface

The public interface used by the Borders API to wrap nodes with zero or more Border implementations. ControlsFX ships with a few Border implementations (current EmptyBorders, LineBorders, and EtchedBorders). As noted in Borders#addBorder(Border), this interface is relatively pointless, unless you plan to wrap a node with multiple borders and you want to use a custom Border implementation for at least one border. In this case, you can simply call Borders#addBorder(Border) with your custom border, when appropriate.

Method Summary

Modifier and TypeMethod and Description
public Node
wrap(Node n)

Given a Node, this method should return a Node that contains the original Node and also has wrapped it with an appropriate border.

Method Detail

wrapback to summary
public Node wrap(Node n)

Given a Node, this method should return a Node that contains the original Node and also has wrapped it with an appropriate border.

org.controlsfx.tools back to summary

public Class Borders.EmptyBorders

extends Object
Class Inheritance

A fluent API that is only indirectly instantiable via the Borders fluent API, and which allows for an empty border to be wrapped around a given Node.

Field Summary

Modifier and TypeField and Description
private double
private double
private final Borders
private double
private double

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Borders
build()

Builds the Border and adds it to the list of borders to wrap around the given Node (which will be constructed and returned when Borders#build() is called.

public Node
buildAll()

A convenience method, this is equivalent to calling build() followed by Borders#build().

private BorderStroke
public Borders.EmptyBorders
padding(double padding)

Specifies that the wrapped Node should have the given padding around all four sides of itself.

public Borders.EmptyBorders
padding(double top, double right, double bottom, double left)

Specifies that the wrapped Node should be wrapped with the given padding for each of its four sides, going in the order top, right, bottom, and finally left.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bottomback to summary
private double bottom
leftback to summary
private double left
parentback to summary
private final Borders parent
rightback to summary
private double right
topback to summary
private double top

Constructor Detail

EmptyBordersback to summary
private EmptyBorders(Borders parent)

Method Detail

buildback to summary
public Borders build()

Builds the Border and adds it to the list of borders to wrap around the given Node (which will be constructed and returned when Borders#build() is called.

buildAllback to summary
public Node buildAll()

A convenience method, this is equivalent to calling build() followed by Borders#build(). In other words, calling this will return the original Node wrapped in all its borders specified.

buildStrokeback to summary
private BorderStroke buildStroke()
paddingback to summary
public Borders.EmptyBorders padding(double padding)

Specifies that the wrapped Node should have the given padding around all four sides of itself.

paddingback to summary
public Borders.EmptyBorders padding(double top, double right, double bottom, double left)

Specifies that the wrapped Node should be wrapped with the given padding for each of its four sides, going in the order top, right, bottom, and finally left.

org.controlsfx.tools back to summary

public Class Borders.EtchedBorders

extends Object
Class Inheritance

A fluent API that is only indirectly instantiable via the Borders fluent API, and which allows for an etched border to be wrapped around a given Node.

Field Summary

Modifier and TypeField and Description
private double
private double
private Color
private double
private double
private double
private double
private double
private double
private double
private double
private final Borders
private boolean
private Color
private String
private double
private double

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Borders
build()

Builds the Border and adds it to the list of borders to wrap around the given Node (which will be constructed and returned when Borders#build() is called.

public Node
buildAll()

A convenience method, this is equivalent to calling build() followed by Borders#build().

public Borders.EtchedBorders
highlight(Color highlight)

Specifies the highlight colour to use in the etched border.

public Borders.EtchedBorders
innerPadding(double padding)

Specifies the inner padding of the four lines of this border.

public Borders.EtchedBorders
innerPadding(double topPadding, double rightPadding, double bottomPadding, double leftPadding)

Specifies that the line wrapping the node should have inner padding as specified, with each padding being independently configured, going in the order top, right, bottom, and left.

public Borders.EtchedBorders
outerPadding(double padding)

Specifies the outer padding of the four lines of this border.

public Borders.EtchedBorders
outerPadding(double topPadding, double rightPadding, double bottomPadding, double leftPadding)

Specifies that the line wrapping the node should have outer padding as specified, with each padding being independently configured, going in the order top, right, bottom, and left.

public Borders.EtchedBorders
radius(double radius)

Specifies the radius of the four corners of the lines of this border.

public Borders.EtchedBorders
radius(double topLeft, double topRight, double bottomRight, double bottomLeft)

Specifies that the etched line wrapping the node should have corner radii as specified, with each radius being independently configured, going in the order top-left, top-right, bottom-right, and finally bottom-left.

public Borders.EtchedBorders
raised()

Specifies the order in which the highlight and shadow colours are placed.

public Borders.EtchedBorders
shadow(Color shadow)

Specifies the shadow colour to use in the etched border.

public Borders.EtchedBorders
title(String title)

If desired, this specifies the title text to show in this border.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bottomLeftRadiusback to summary
private double bottomLeftRadius
bottomRightRadiusback to summary
private double bottomRightRadius
highlightColorback to summary
private Color highlightColor
innerBottomPaddingback to summary
private double innerBottomPadding
innerLeftPaddingback to summary
private double innerLeftPadding
innerRightPaddingback to summary
private double innerRightPadding
innerTopPaddingback to summary
private double innerTopPadding
outerBottomPaddingback to summary
private double outerBottomPadding
outerLeftPaddingback to summary
private double outerLeftPadding
outerRightPaddingback to summary
private double outerRightPadding
outerTopPaddingback to summary
private double outerTopPadding
parentback to summary
private final Borders parent
raisedback to summary
private boolean raised
shadowColorback to summary
private Color shadowColor
titleback to summary
private String title
topLeftRadiusback to summary
private double topLeftRadius
topRightRadiusback to summary
private double topRightRadius

Constructor Detail

EtchedBordersback to summary
private EtchedBorders(Borders parent)

Method Detail

buildback to summary
public Borders build()

Builds the Border and adds it to the list of borders to wrap around the given Node (which will be constructed and returned when Borders#build() is called.

buildAllback to summary
public Node buildAll()

A convenience method, this is equivalent to calling build() followed by Borders#build(). In other words, calling this will return the original Node wrapped in all its borders specified.

highlightback to summary
public Borders.EtchedBorders highlight(Color highlight)

Specifies the highlight colour to use in the etched border.

innerPaddingback to summary
public Borders.EtchedBorders innerPadding(double padding)

Specifies the inner padding of the four lines of this border.

innerPaddingback to summary
public Borders.EtchedBorders innerPadding(double topPadding, double rightPadding, double bottomPadding, double leftPadding)

Specifies that the line wrapping the node should have inner padding as specified, with each padding being independently configured, going in the order top, right, bottom, and left.

outerPaddingback to summary
public Borders.EtchedBorders outerPadding(double padding)

Specifies the outer padding of the four lines of this border.

outerPaddingback to summary
public Borders.EtchedBorders outerPadding(double topPadding, double rightPadding, double bottomPadding, double leftPadding)

Specifies that the line wrapping the node should have outer padding as specified, with each padding being independently configured, going in the order top, right, bottom, and left.

radiusback to summary
public Borders.EtchedBorders radius(double radius)

Specifies the radius of the four corners of the lines of this border.

radiusback to summary
public Borders.EtchedBorders radius(double topLeft, double topRight, double bottomRight, double bottomLeft)

Specifies that the etched line wrapping the node should have corner radii as specified, with each radius being independently configured, going in the order top-left, top-right, bottom-right, and finally bottom-left.

raisedback to summary
public Borders.EtchedBorders raised()

Specifies the order in which the highlight and shadow colours are placed. A raised etched border has the shadow colour on the outside of the border, whereas a non-raised (or lowered) etched border has the shadow colour on the inside of the border.

shadowback to summary
public Borders.EtchedBorders shadow(Color shadow)

Specifies the shadow colour to use in the etched border.

titleback to summary
public Borders.EtchedBorders title(String title)

If desired, this specifies the title text to show in this border.

org.controlsfx.tools back to summary

public Class Borders.LineBorders

extends Object
Class Inheritance

A fluent API that is only indirectly instantiable via the Borders fluent API, and which allows for a line border to be wrapped around a given Node.

Field Summary

Modifier and TypeField and Description
private Color
private double
private double
private double
private double
private double
private double
private double
private Color
private double
private double
private double
private double
private double
private final Borders
private Color
private double
private BorderStrokeStyle
private String
private Color
private double
private double
private double

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Borders
build()

Builds the Border and adds it to the list of borders to wrap around the given Node (which will be constructed and returned when Borders#build() is called.

public Node
buildAll()

A convenience method, this is equivalent to calling build() followed by Borders#build().

public Borders.LineBorders
color(Color color)

Specifies the colour to use for all four sides of this border.

public Borders.LineBorders
color(Color topColor, Color rightColor, Color bottomColor, Color leftColor)

Specifies that the wrapped Node should be wrapped with the given colours for each of its four sides, going in the order top, right, bottom, and finally left.

public Borders.LineBorders
innerPadding(double padding)

Specifies the outer padding of the four lines of this border.

public Borders.LineBorders
innerPadding(double topPadding, double rightPadding, double bottomPadding, double leftPadding)

Specifies that the line wrapping the node should have inner padding as specified, with each padding being independently configured, going in the order top, right, bottom, and left.

public Borders.LineBorders
outerPadding(double padding)

Specifies the inner padding of the four lines of this border.

public Borders.LineBorders
outerPadding(double topPadding, double rightPadding, double bottomPadding, double leftPadding)

Specifies that the line wrapping the node should have outer padding as specified, with each padding being independently configured, going in the order top, right, bottom, and left.

public Borders.LineBorders
radius(double radius)

Specifies the radius of the four corners of the line of this border.

public Borders.LineBorders
radius(double topLeft, double topRight, double bottomRight, double bottomLeft)

Specifies that the line wrapping the node should have corner radii as specified, with each radius being independently configured, going in the order top-left, top-right, bottom-right, and finally bottom-left.

public Borders.LineBorders
strokeStyle(BorderStrokeStyle strokeStyle)

Specifies which BorderStrokeStyle to use for this line border.

public Borders.LineBorders
thickness(double thickness)

Specifies the thickness of the line to use on all four sides of this border.

public Borders.LineBorders
thickness(double topThickness, double rightThickness, double bottomThickness, double leftThickness)

Specifies that the wrapped Node should be wrapped with the given line thickness for each of its four sides, going in the order top, right, bottom, and finally left.

public Borders.LineBorders
title(String title)

If desired, this specifies the title text to show in this border.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bottomColorback to summary
private Color bottomColor
bottomLeftRadiusback to summary
private double bottomLeftRadius
bottomRightRadiusback to summary
private double bottomRightRadius
bottomThicknessback to summary
private double bottomThickness
innerBottomPaddingback to summary
private double innerBottomPadding
innerLeftPaddingback to summary
private double innerLeftPadding
innerRightPaddingback to summary
private double innerRightPadding
innerTopPaddingback to summary
private double innerTopPadding
leftColorback to summary
private Color leftColor
leftThicknessback to summary
private double leftThickness
outerBottomPaddingback to summary
private double outerBottomPadding
outerLeftPaddingback to summary
private double outerLeftPadding
outerRightPaddingback to summary
private double outerRightPadding
outerTopPaddingback to summary
private double outerTopPadding
parentback to summary
private final Borders parent
rightColorback to summary
private Color rightColor
rightThicknessback to summary
private double rightThickness
strokeStyleback to summary
private BorderStrokeStyle strokeStyle
titleback to summary
private String title
topColorback to summary
private Color topColor
topLeftRadiusback to summary
private double topLeftRadius
topRightRadiusback to summary
private double topRightRadius
topThicknessback to summary
private double topThickness

Constructor Detail

LineBordersback to summary
private LineBorders(Borders parent)

Method Detail

buildback to summary
public Borders build()

Builds the Border and adds it to the list of borders to wrap around the given Node (which will be constructed and returned when Borders#build() is called.

buildAllback to summary
public Node buildAll()

A convenience method, this is equivalent to calling build() followed by Borders#build(). In other words, calling this will return the original Node wrapped in all its borders specified.

colorback to summary
public Borders.LineBorders color(Color color)

Specifies the colour to use for all four sides of this border.

colorback to summary
public Borders.LineBorders color(Color topColor, Color rightColor, Color bottomColor, Color leftColor)

Specifies that the wrapped Node should be wrapped with the given colours for each of its four sides, going in the order top, right, bottom, and finally left.

innerPaddingback to summary
public Borders.LineBorders innerPadding(double padding)

Specifies the outer padding of the four lines of this border.

innerPaddingback to summary
public Borders.LineBorders innerPadding(double topPadding, double rightPadding, double bottomPadding, double leftPadding)

Specifies that the line wrapping the node should have inner padding as specified, with each padding being independently configured, going in the order top, right, bottom, and left.

outerPaddingback to summary
public Borders.LineBorders outerPadding(double padding)

Specifies the inner padding of the four lines of this border.

outerPaddingback to summary
public Borders.LineBorders outerPadding(double topPadding, double rightPadding, double bottomPadding, double leftPadding)

Specifies that the line wrapping the node should have outer padding as specified, with each padding being independently configured, going in the order top, right, bottom, and left.

radiusback to summary
public Borders.LineBorders radius(double radius)

Specifies the radius of the four corners of the line of this border.

radiusback to summary
public Borders.LineBorders radius(double topLeft, double topRight, double bottomRight, double bottomLeft)

Specifies that the line wrapping the node should have corner radii as specified, with each radius being independently configured, going in the order top-left, top-right, bottom-right, and finally bottom-left.

strokeStyleback to summary
public Borders.LineBorders strokeStyle(BorderStrokeStyle strokeStyle)

Specifies which BorderStrokeStyle to use for this line border. By default this is BorderStrokeStyle#SOLID, but you can use any other style (such as BorderStrokeStyle#DASHED, BorderStrokeStyle#DOTTED, or a custom style built using BorderStrokeStyle#BorderStrokeStyle(javafx.scene.shape.StrokeType, javafx.scene.shape.StrokeLineJoin, javafx.scene.shape.StrokeLineCap, double, double, List).

thicknessback to summary
public Borders.LineBorders thickness(double thickness)

Specifies the thickness of the line to use on all four sides of this border.

thicknessback to summary
public Borders.LineBorders thickness(double topThickness, double rightThickness, double bottomThickness, double leftThickness)

Specifies that the wrapped Node should be wrapped with the given line thickness for each of its four sides, going in the order top, right, bottom, and finally left.

titleback to summary
public Borders.LineBorders title(String title)

If desired, this specifies the title text to show in this border.

org.controlsfx.tools back to summary

private Class Borders.StrokeBorder

extends Object
implements Border
Class Inheritance
All Implemented Interfaces
org.controlsfx.tools.Borders.Border

Private support classes

Field Summary

Modifier and TypeField and Description
private final BorderStroke[]
private static final double
private final String
private static final int

Constructor Summary

AccessConstructor and Description
public
StrokeBorder(String title, BorderStroke... borderStrokes)

Method Summary

Modifier and TypeMethod and Description
public Node
wrap(final Node n)

Implements org.controlsfx.tools.Borders.Border.wrap.

Given a Node, this method should return a Node that contains the original Node and also has wrapped it with an appropriate border.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

borderStrokesback to summary
private final BorderStroke[] borderStrokes
GAP_PADDINGback to summary
private static final double GAP_PADDING
titleback to summary
private final String title
TITLE_PADDINGback to summary
private static final int TITLE_PADDING

Constructor Detail

StrokeBorderback to summary
public StrokeBorder(String title, BorderStroke... borderStrokes)

Method Detail

wrapback to summary
public Node wrap(final Node n)

Implements org.controlsfx.tools.Borders.Border.wrap.

Doc from org.controlsfx.tools.Borders.Border.wrap.

Given a Node, this method should return a Node that contains the original Node and also has wrapped it with an appropriate border.

Annotations
@Override