我使用JavaFX 文字对象,我将其绑定到进度指示器:
我希望它能显示完成了多少(%)的工作。
代码:
text.textProperty().bind(indicator.progressProperty().multiply(100.00).asString("%.02f %%"));
如何将-100.00设为0.00?我只是无法弄清楚...(我使用了if else进行乘法,除法但它没有wkorking(?" ... ":" ...&#34)
。感谢您的帮助!
答案 0 :(得分: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 %%"));