List of usage examples for javafx.beans.binding ObjectBinding addListener
@Override public void addListener(ChangeListener<? super T> listener)
From source file:Main.java
public static void main(String[] args) { ObjectProperty<Lighting> root = new SimpleObjectProperty<Lighting>(); final ObjectBinding<Color> colorBinding = Bindings.select(root, "light", "color"); colorBinding.addListener(new ChangeListener<Color>() { @Override/* w w w . java 2 s. co m*/ public void changed(ObservableValue<? extends Color> observableValue, Color oldValue, Color newValue) { System.out.println(oldValue + "new = " + newValue); } }); Light firstLight = new Light.Point(); firstLight.setColor(Color.BLACK); Light secondLight = new Light.Point(); secondLight.setColor(Color.WHITE); Lighting firstLighting = new Lighting(); firstLighting.setLight(firstLight); root.set(firstLighting); firstLighting.setLight(firstLight); firstLight.setColor(Color.RED); }