Example usage for javafx.beans.property SimpleIntegerProperty SimpleIntegerProperty

List of usage examples for javafx.beans.property SimpleIntegerProperty SimpleIntegerProperty

Introduction

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

Prototype

public SimpleIntegerProperty(int initialValue) 

Source Link

Document

The constructor of IntegerProperty

Usage

From source file:Main.java

public static void main(String[] args) {
    IntegerProperty intProperty = new SimpleIntegerProperty(1024);
    System.out.println("intProperty = " + intProperty);
}

From source file:Main.java

public static void main(String[] args) {
    IntegerProperty intProperty = new SimpleIntegerProperty(1024);
    System.out.println("intProperty = " + intProperty);
    System.out.println("intProperty.getValue() = " + intProperty.getValue().intValue());
}

From source file:Main.java

public static void main(String[] args) {
    IntegerProperty intProperty = new SimpleIntegerProperty(1024);
    System.out.println("intProperty = " + intProperty);
    System.out.println("intProperty.get() = " + intProperty.get());
}

From source file:Main.java

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

    otherProperty.bind(intProperty);//from  w  w  w.j a  v  a2 s.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);/*  ww w .  j  a  v  a  2 s. c o  m*/
    System.out.println(sum.getValue());
    num1.set(2);
    System.out.println(sum.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));//w  w  w .  ja va2 s. c  o m

    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) {

    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);//from   w w  w  .  j  a  v a  2  s.  co m
    height.set(200);

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

From source file:Main.java

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

    // Adding a change listener with anonymous inner class
    xProperty.addListener(new ChangeListener<Number>() {
        @Override/*from  ww  w.j  a  v  a2  s . c o  m*/
        public void changed(ObservableValue<? extends Number> ov, Number oldVal, Number newVal) {
            System.out.println("old value:" + oldVal);
            System.out.println("new value:" + newVal);
        }
    });

    // Adding a change listener with lambda expression
    xProperty.addListener((ObservableValue<? extends Number> ov, Number oldVal, Number newVal) -> {
        System.out.println("old value:" + oldVal);
        System.out.println("new value:" + newVal);
    });
}

From source file:Main.java

public static void main(String[] args) {
    // Area = width * height
    IntegerProperty width = new SimpleIntegerProperty(10);
    IntegerProperty height = new SimpleIntegerProperty(10);
    NumberBinding area = width.multiply(height);
    System.out.println(area.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 .  ja  v  a2 s  . com*/

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