Example usage for javafx.beans.property IntegerProperty set

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

Introduction

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

Prototype

void set(int value);

Source Link

Document

Set the wrapped value.

Usage

From source file:Main.java

public static void main(String[] args) {
    IntegerProperty intProperty = new SimpleIntegerProperty(1024);
    IntegerProperty otherProperty = new SimpleIntegerProperty(0);

    otherProperty.bind(intProperty);//ww  w.j a  va2s. c  o m
    intProperty.set(7168);
    otherProperty.unbind();
    intProperty.set(8192);

}

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);//  www .j a  v a 2 s.  com
    System.out.println(sum.getValue());
    num1.set(2);
    System.out.println(sum.getValue());
}

From source file:Main.java

public static void main(String[] args) {
    IntegerProperty counter = new SimpleIntegerProperty(100);

    // Add a change listener to the counter property
    counter.addListener(Main::changed);/*from w w w .j av a  2s .c  o  m*/

    System.out.println("Before changing the counter value-1");
    counter.set(101);
    System.out.println("After changing the counter value-1");

    System.out.println();
    System.out.println("Before changing the counter value-2");
    counter.set(102);
    System.out.println("After changing the counter value-2");

    // Try setting the same value
    System.out.println();
    System.out.println("Before changing the counter value-3");
    counter.set(102); // No change event will be fired.
    System.out.println("After changing the counter value-3");

    // Try setting a different value
    System.out.println();
    System.out.println("Before changing the counter value-4");
    counter.set(103);
    System.out.println("After changing the counter value-4");
}

From source file:Main.java

public static void main(String[] args) {
    IntegerProperty i = new SimpleIntegerProperty(null, "i", 1024);
    LongProperty l = new SimpleLongProperty(null, "l", 0L);

    System.out.println("i.get() = " + i.get());
    System.out.println("l.get() = " + l.get());

    l.bind(i);/*  ww w .jav a  2  s.  co  m*/

    i.set(2048);

    System.out.println("i.get() = " + i.get());
    System.out.println("l.get() = " + l.get());

    l.unbind();
    System.out.println("Unbound l to i, f to l, d to f.");

    i.bind(l);
    System.out.println("Bound f to d, l to f, i to l.");

    System.out.println("Calling d.set(10000000000L).");
    i.set(100);

    System.out.println("l.get() = " + l.get());
    System.out.println("i.get() = " + i.get());
}

From source file:Main.java

public static void main(String[] args) {
    IntegerProperty x1 = new SimpleIntegerProperty(0);
    IntegerProperty y1 = new SimpleIntegerProperty(0);

    final NumberBinding area = x1.multiply(y1).divide(2.0D);

    StringExpression output = Bindings.format("For A(%d,%d), the area is %3.1f", x1, y1, area);

    x1.set(0);
    y1.set(0);// w w  w.j  ava2 s .  c  om

    System.out.println(output.get());

    x1.set(10);
    y1.set(110);

    System.out.println(output.get());
}

From source file:Main.java

public static void main(String[] args) {

    final IntegerProperty width = new SimpleIntegerProperty(10);
    final IntegerProperty height = new SimpleIntegerProperty(10);

    NumberBinding area = width.multiply(height);

    System.out.println(width.get() + " " + height.get());
    System.out.println(area.getValue());

    width.set(100);
    height.set(200);/*  w ww. j a  v a 2 s  .co  m*/

    System.out.println(width.get() + " " + height.get());
    System.out.println(area.getValue());
}

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));//from   w w  w.  j a v a  2s  . com

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

    // Change x and y
    x.set(15);
    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());
}

From source file:Main.java

public static void main(String[] args) {
    IntegerProperty intProperty = new SimpleIntegerProperty(1024);
    final ChangeListener changeListener = new ChangeListener() {
        @Override/* w w w  .  j a v a  2  s.  com*/
        public void changed(ObservableValue observableValue, Object oldValue, Object newValue) {
            System.out.println("oldValue:" + oldValue + ", newValue = " + newValue);
        }
    };

    intProperty.addListener(changeListener);
    intProperty.set(5120);

    intProperty.removeListener(changeListener);

    intProperty.set(6144);
}

From source file:Main.java

public static void main(String[] args) {
    IntegerProperty x1 = new SimpleIntegerProperty(0);
    IntegerProperty y1 = new SimpleIntegerProperty(0);

    final NumberBinding x1y2 = Bindings.multiply(x1, y1);

    final NumberBinding sum1 = Bindings.add(x1y2, 2);
    final NumberBinding diff1 = Bindings.subtract(sum1, 1);
    final NumberBinding determinant = Bindings.subtract(diff1, 2);
    final NumberBinding area = Bindings.divide(determinant, 2.0D);

    x1.set(0);
    y1.set(0);//ww  w  .j  a  v  a2s . c  om

    printResult(x1, y1, area);

    x1.set(1);
    y1.set(0);

    printResult(x1, y1, area);
}

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);/*from w w w  .  j  a v a2 s.c o  m*/

    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();
    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);
}