Reputation: 530
I'm trying to create a BooleanProperty
for my CustomPane
, let's call it isEmpty
.
This property should be true when a collection (filled at runtime) of TextField
objects matches a condition. This list does not change its content once given.
In this case the condition is that all fields must be empty (no text in any of the fields).
So when the CustomPane
object is constructed, I have the list of fields and I should bind all their .textProperty().isEmpty()
toghether.
Any suggetions on how I could do this?
Upvotes: 1
Views: 1467
Reputation: 7058
You could do something like this:
private BooleanBinding areTheyEmptyBinding(List<TextField> list){
BooleanBinding bind = new SimpleBooleanProperty(false).not();
for (TextField text: list)
bind = bind.and(text.textProperty().isEmpty());
return bind;
}
Upvotes: 4