0
我有一個DoubleProperty(price
),我想要第二個DoubleProperty(discountedPrice
)綁定到price - 25%
。如何將DoubleProperty綁定到表達式?
所以我想我會用multiply
方法,但它似乎並不如預期的工作:
DoubleProperty price = new SimpleDoubleProperty();
DoubleProperty pctDiscount = new SimpleDoubleProperty();
pctDiscount.bind(price.multiply(0.75));
price.set(100);
System.out.println(pctDiscount);
我期待的節目輸出75,但輸出是:
DoubleProperty [bound,invalid]