Java Reference
In-Depth Information
following code applies JavaFX CSS border styles to a horizontal box region (
HBox
)
using the
setStyle()
method:
String cssDefault = "-fx-border-color: blue;\n"
+ "-fx-border-insets: 5;\n"
+ "-fx-border-width: 3;\n"
+ "-fx-border-style: dashed;\n";
final ImageView imv = new ImageView();
...//
final HBox pictureRegion = new HBox();
pictureRegion.setStyle(cssDefault);
pictureRegion.getChildren().add(imv);
14-9. Binding Expressions
Problem
You want to synchronize changes between two values.
Solution
Use the
javafx.beans.binding.*
and
javafx.beans.property.*
pack-
ages to bind variables. There is more than one scenario to consider when binding val-
ues or properties. This recipe demonstrates the following three binding strategies:
•
Bidirectional binding on a Java Bean
•
High-level binding using the Fluent API
•
Low-level binding using
javafx.beans.binding.*
binding ob-
jects
The following code is a console application implementing these three strategies.
The console application will output property values based on various binding scenari-
os. The first scenario is a bidirectional binding between a string property variable and a
string property owned by a domain object (
Contact
), such as the
firstName
prop-
erty. The next scenario is a high-level binding using a fluent interface API to calculate
the area of rectangle. The last scenario is using a low-level binding strategy to calculate