Example usage for javafx.beans.binding NumberBinding addListener

List of usage examples for javafx.beans.binding NumberBinding addListener

Introduction

In this page you can find the example usage for javafx.beans.binding NumberBinding addListener.

Prototype

void addListener(ChangeListener<? super T> listener);

Source Link

Document

Adds a ChangeListener which will be notified whenever the value of the ObservableValue changes.

Usage

From source file:MyClass.java

public static void main(String[] args) {

    MyClass myObject1 = new MyClass();
    MyClass myObject2 = new MyClass();
    MyClass myObject3 = new MyClass();

    NumberBinding total = Bindings.add(myObject1.amountDueProperty().add(myObject2.amountDueProperty()),
            myObject3.amountDueProperty());
    total.addListener(new InvalidationListener() {
        @Override/*  www .ja  v  a 2s.  c  om*/
        public void invalidated(Observable o) {
            System.out.println("The binding is now invalid.");
        }
    });
    myObject1.setAmountDue(200.00);
    myObject2.setAmountDue(100.00);
    myObject3.setAmountDue(75.00);
    System.out.println(total.getValue());
    myObject3.setAmountDue(150.00);
    System.out.println(total.getValue());
}