Subclass DoubleBinding with custom computeValue method : DoubleBinding « JavaFX « Java






Subclass DoubleBinding with custom computeValue method

 


import javafx.beans.binding.DoubleBinding;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;

public class Main {
    public static void main(String[] args) {
        final DoubleProperty a = new SimpleDoubleProperty(0);
        final DoubleProperty b = new SimpleDoubleProperty(0);
        final DoubleProperty c = new SimpleDoubleProperty(0);

        DoubleBinding area = new DoubleBinding() {
            {
                super.bind(a, b, c);
            }
            @Override
            protected double computeValue() {
                double a0 = a.get();
                double b0 = b.get();
                double c0 = c.get();

                return a0 * b0 * c0;

            }
        };

        a.set(2);
        b.set(2);
        c.set(2);
        System.out.println(area.get());
    }
}

   
  








Related examples in the same category

1.Custome DoubleBinding by subclassing
2.Override computeValue from DoubleBinding