我有一个 DoubleProperty( price
),我希望将第二个 DoubleProperty( discountedPrice
) 绑定到price - 25%
.
所以我想我会使用该multiply
方法,但它似乎没有按预期工作:
DoubleProperty price = new SimpleDoubleProperty();
DoubleProperty pctDiscount = new SimpleDoubleProperty();
pctDiscount.bind(price.multiply(0.75));
price.set(100);
System.out.println(pctDiscount);
我期待程序输出 75 但输出是:
DoubleProperty [绑定,无效]