- java.lang.Object
-
- org.controlsfx.tools.Borders
-
public final class Borders extends Object
A utility class that allows you to wrap JavaFXNodeswith a border, in a way somewhat analogous to the SwingBorderFactory(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
build()method. To use the Borders class, you simply callwrap(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:

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:

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:

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 Class Summary
Nested Classes Modifier and Type Class Description static interfaceBorders.BorderThe public interface used by theBordersAPI to wrap nodes with zero or more Border implementations.classBorders.EmptyBordersA fluent API that is only indirectly instantiable via theBordersfluent API, and which allows for anempty borderto be wrapped around a given Node.classBorders.EtchedBordersA fluent API that is only indirectly instantiable via theBordersfluent API, and which allows for anetched borderto be wrapped around a given Node.classBorders.LineBordersA fluent API that is only indirectly instantiable via theBordersfluent API, and which allows for aline borderto be wrapped around a given Node.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BordersaddBorder(Borders.Border border)Allows for developers to develop customBorders.Borderimplementations, and to wrap them around a Node.Nodebuild()Returns the original node wrapped in zero or more borders, as specified using the fluent API.Borders.EmptyBordersemptyBorder()Often times it is useful to have a bit of whitespace around a Node, to separate it from what it is next to.Borders.EtchedBordersetchedBorder()The etched border look is essentially equivalent to thelineBorder()look, except rather than one line, there are two.Borders.LineBorderslineBorder()Creates a nice, simple border around the node.static Borderswrap(Node n)Fluent API entry method(s)
-
-
-
Method Detail
-
emptyBorder
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).
-
etchedBorder
public Borders.EtchedBorders etchedBorder()
The etched border look is essentially equivalent to thelineBorder()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 inBorders.EtchedBordersfor more information.
-
lineBorder
public Borders.LineBorders lineBorder()
Creates a nice, simple border around the node. Note that there are many configuration options inBorders.LineBorders, so explore it carefully.
-
addBorder
public Borders addBorder(Borders.Border border)
Allows for developers to develop customBorders.Borderimplementations, and to wrap them around a Node. Note that of course this is mostly redundant (as you could just callBorders.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.
-
build
public Node build()
Returns the original node wrapped in zero or more borders, as specified using the fluent API.
-
-