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
build() method. To use the Borders class, you simply call
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:
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.
-
嵌套类概要
嵌套类修饰符和类型类说明static interfaceThe public interface used by theBordersAPI to wrap nodes with zero or more Border implementations.static classA fluent API that is only indirectly instantiable via theBordersfluent API, and which allows for anempty borderto be wrapped around a given Node.static classA fluent API that is only indirectly instantiable via theBordersfluent API, and which allows for anetched borderto be wrapped around a given Node.static classA fluent API that is only indirectly instantiable via theBordersfluent API, and which allows for aline borderto be wrapped around a given Node.private static final recordBorder implementations. -
字段概要
字段修饰符和类型字段说明private final List<Borders.Border> private static final javafx.scene.paint.Colorprivate final javafx.scene.Node -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明addBorder(Borders.Border border) Allows for developers to develop customBorders.Borderimplementations, and to wrap them around a Node.javafx.scene.Nodebuild()Returns the original node wrapped in zero or more borders, as specified using the fluent API.Often times it is useful to have a bit of whitespace around a Node, to separate it from what it is next to.The etched border look is essentially equivalent to thelineBorder()look, except rather than one line, there are two.Creates a nice, simple border around the node.static Borderswrap(javafx.scene.Node n) initialize Borders.
-
字段详细资料
-
DEFAULT_BORDER_COLOR
private static final javafx.scene.paint.Color DEFAULT_BORDER_COLOR -
node
private final javafx.scene.Node node -
borders
-
-
构造器详细资料
-
Borders
private Borders(javafx.scene.Node n)
-
-
方法详细资料
-
wrap
initialize Borders. -
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
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
Creates a nice, simple border around the node. Note that there are many configuration options inBorders.LineBorders, so explore it carefully. -
addBorder
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 javafx.scene.Node build()Returns the original node wrapped in zero or more borders, as specified using the fluent API.
-