Skip to content

Instantly share code, notes, and snippets.

@omernaci
Created April 13, 2017 19:21
Show Gist options
  • Save omernaci/4a4f171a777a8bdad5b188bf7930b092 to your computer and use it in GitHub Desktop.
Save omernaci/4a4f171a777a8bdad5b188bf7930b092 to your computer and use it in GitHub Desktop.
JavaFX Binding Sample
// Main.java class
import javafx.beans.binding.NumberBinding;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
/**
*
* @author omers
*/
public class Main {
public static void main(String[] args) {
IntegerProperty num1 = new SimpleIntegerProperty(1);
IntegerProperty num2 = new SimpleIntegerProperty(2);
NumberBinding sum = num1.add(num2);
System.out.println(sum.getValue());
num1.set(2);
System.out.println(sum.getValue());
}
}
// Output :
// 3
// 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment