Java examples for JavaFX:Bindable Properties
Data Binding with Low-level binding API in JavaFX
import javafx.beans.binding.DoubleBinding; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; public class Main { public static void main(String[] args) { // volume = 4/3 * pi r^3 final DoubleProperty radius = new SimpleDoubleProperty(2); DoubleBinding volumeOfSphere = new DoubleBinding() { {/*from w w w .j a va 2 s .c o m*/ super.bind(radius); } @Override protected double computeValue() { return (4 / 3 * Math.PI * Math.pow(radius.get(), 3)); } }; System.out.println("Current - radius for Sphere: " + radius.get()); System.out.println("Current - volume for Sphere: " + volumeOfSphere.get()); radius.set(50); System.out.println("After - radius for Sphere: " + radius.get()); System.out.println("After - volume for Sphere: " + volumeOfSphere.get()); } }