2016-04-21 51 views
0

我用一個JavaFX 文本對象,我將它綁定到一個進度指標格式的JavaFX DoubleProperty爲-100.00

我想讓它顯示多少百分比(%)的工作就完成了。

代碼:

text.textProperty().bind(indicator.progressProperty().multiply(100.00).asString("%.02f %%")); 

如何讓這個-100.00是0.00我實在不明白這一點...(我用的if else到乘法,除法,但它不wkorking( ? 「... 」:!「 ......」)

感謝您的幫助

回答

2

使用

text.textProperty().bind(
    Bindings.when(indicator.progressProperty().lessThan(0)) 
    .then("0.00") 
    .otherwise(indicator.progressProperty().multiply(100.00).asString("%.02f %%"))); 

text.textProperty().bind(
    Bindings.max(0, indicator.progressProperty()).multiply(100.00).asString("%.02f %%")); 
+0

甚至不知道這些方法存在.....謝謝! – GOXR3PLUS