Command window output:
C:\ece538\JavaFX\JavaPP\ch15\ex4>java ObservablePropertyDemo The new value is 4.5 The new value is 12.1
ObservablePropertyDemo.javaimport javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
public class ObservablePropertyDemo {
public static void main(String[] args) {
DoubleProperty balance = new SimpleDoubleProperty();
balance.addListener(new InvalidationListener() {
public void invalidated(Observable ov) {
System.out.println("The new value is " +
balance.doubleValue());
}
});
balance.set(4.5);
balance.set(12.1);
}
}
Maintained by John Loomis, updated Sun Feb 11 15:23:10 2018