Create NumberBinding with IntegerProperty.multiply : NumberBinding « JavaFX « Java






Create NumberBinding with IntegerProperty.multiply

 
import javafx.beans.binding.Bindings;
import javafx.beans.binding.NumberBinding;
import javafx.beans.binding.StringExpression;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;

public class Main {
    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);

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

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

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

   
  








Related examples in the same category

1.SimpleIntegerProperty and NumberBinding
2.Using the NumberBinding in the following Bindings