Example usage for javafx.beans.property IntegerProperty add

List of usage examples for javafx.beans.property IntegerProperty add

Introduction

In this page you can find the example usage for javafx.beans.property IntegerProperty add.

Prototype

@Override
    public DoubleBinding add(final double other) 

Source Link

Usage

From source file:Main.java

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);//  ww  w .j a va 2 s .  c o m
    System.out.println(sum.getValue());
}

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 ww .  j a v a2 s.  com*/
    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);
}

From source file:Main.java

public static void main(String[] args) {
    // Create three properties
    IntegerProperty x = new SimpleIntegerProperty(10);
    IntegerProperty y = new SimpleIntegerProperty(20);
    IntegerProperty z = new SimpleIntegerProperty(60);

    // Create the binding z = x + y
    z.bind(x.add(y));

    System.out.println("After binding z: Bound = " + z.isBound() + ", z = " + z.get());

    // Change x and y
    x.set(15);/*from ww  w.j  av a 2s  .c  o m*/
    y.set(19);
    System.out.println("After changing x and y: Bound = " + z.isBound() + ", z = " + z.get());

    // Unbind z
    z.unbind();

    // Will not affect the value of z as it is not bound
    // to x and y anymore
    x.set(100);
    y.set(200);
    System.out.println("After unbinding z: Bound = " + z.isBound() + ", z = " + z.get());
}