Java Reference
In-Depth Information
the volume of a sphere. The difference between the high-and low-level binding is that
the high level uses methods such as multiply() and subtract() instead of the
operators * and - . When using low-level binding, you use a derived NumberBind-
ing class such as a DoubleBinding class. With a DoubleBinding class you
override its computeValue() method so that you can use the familiar operators
such as * and - to formulate complex math equations:
package org.java8recipes.chapter14.recipe14_09;
import javafx.beans.binding.DoubleBinding;
import javafx.beans.binding.NumberBinding;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
/**
* Recipe 14-9: Binding Expressions
* @author cdea
* Update: J. Juneau
*/
public class BindingExpressions {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Chapter 14-9 Binding
Expressions\n");
System.out.println("Binding a Contact bean
[Bi-directional binding]");
Contact contact = new Contact("John", "Doe");
StringProperty fname = new SimpleStringProperty();
fname.bindBidirectional(contact.firstNameProperty());
StringProperty lname = new SimpleStringProperty();
Search WWH ::




Custom Search