我使用 JavaFX Text 对象,并将其绑定(bind)到进度指示器:
我希望它显示工作完成了多少百分比(%)。
代码:
text.textProperty().bind(indicator.progressProperty().multiply(100.00).asString("%.02f %%"));
如何使 -100.00 变为 0.00 ?我就是想不出来......(我在乘法、除法中使用了 if else 但它不会 wkorking(?"...":".. ”)。
感谢您的帮助!
最佳答案
使用
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 %%"));
关于java - 将 javaFX DoubleProperty 格式设置为 -100.00,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36775098/