Example usage for javafx.beans.binding NumberBinding intValue

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

Introduction

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

Prototype

int intValue();

Source Link

Document

Returns the value of this ObservableNumberValue as an int .

Usage

From source file:Main.java

public static void main(String[] args) {

    IntegerProperty x = new SimpleIntegerProperty(100);
    IntegerProperty y = new SimpleIntegerProperty(200);

    // Create a binding: sum = x + y
    NumberBinding sum = x.add(y);

    System.out.println("After creating sum");
    System.out.println("sum.isValid(): " + sum.isValid());

    // Let us get the value of sum, so it computes its value and
    // becomes valid
    int value = sum.intValue();

    System.out.println();/*from   w w w. j av a 2  s. c o  m*/
    System.out.println("After requesting value");
    System.out.println("sum.isValid(): " + sum.isValid());
    System.out.println("sum = " + value);

    // Change the value of x
    x.set(250);

    System.out.println();
    System.out.println("After changing x");
    System.out.println("sum.isValid(): " + sum.isValid());

    // Get the value of sum again
    value = sum.intValue();

    System.out.println();
    System.out.println("After requesting value");
    System.out.println("sum.isValid(): " + sum.isValid());
    System.out.println("sum = " + value);
}