Java Reference
In-Depth Information
}
public final void setLastName(String lastName) {
this.lastName.setValue(lastName);
}
}
The following output demonstrates the three binding scenarios:
Binding a Contact bean [Bi-directional binding]
Current - StringProperty values : John Doe
Current - Contact values : John Doe
Modifying StringProperty values
After - StringProperty values : Jane Deer
After - Contact values : Jane Deer
A Area of a Rectangle [High level Fluent API]
Current - Width and Height : 10 10
Current - Area of the Rectangle: 100
Modifying width and height
After - Width and Height : 100 700
After - Area of the Rectangle: 70000
A Volume of a Sphere [low level API]
Current - radius for Sphere: 2.0
Current - volume for Sphere: 25.132741228718345
Modifying DoubleProperty radius
After - radius for Sphere: 50.0
After - volume for Sphere: 392699.0816987241
How It Works
Binding implies that at least two values are being synchronized. This means when a de-
pendent variable changes, the other variable changes. JavaFX provides many binding
options that enable developers to synchronize properties in domain objects and GUI
controls. This recipe demonstrates the three common binding scenarios.
One of the easiest ways to bind variables is using a bidirectional bind . This scen-
ario is often used when domain objects contain data that will be bound to a GUI form.
Search WWH ::




Custom Search