Reputation: 684
I've binded a Text property with Long Property
text.textProperty().bind(newValue.referenceNumberProperty().asString());
There is the simply way to replace values <= 0 to empty String ?. I know that asString() method can take a parameter but I dont know how use it. Could you help me ?
Upvotes: 0
Views: 369
Reputation: 82491
As far as the use of the parameter of the asString
method is concerned: It's meaning is explained in the javadoc for Formatter
There is no way to achieve the desired effect using a asString
method alone. You could solve your problem by binding to
Bindings.when(newValue.referenceNumberProperty().greaterThan(0))
.then(newValue.referenceNumberProperty().asString())
.otherwise("")
or to
Bindings.createStringBinding(() -> {
long val = newValue.getReferenceNumber();
return val > 0 ? Long.toString(val) : "";
}, newValue.referenceNumberProperty())
though.
Upvotes: 3