Josh
Josh

Reputation: 13

Binding a button to multiple boolean values javafx

I have 5 textFields and they all have validators that I have created for them. When the field has been validated and is correct, I call a method that sets a group to become visible:

public void fadeInLabel(Group groupName){
    groupName.setOpacity(0);
    groupName.setVisible(true);
    FadeTransition ft = new FadeTransition(Duration.millis(300), groupName);
    ft.setInterpolator(Interpolator.EASE_OUT);
    ft.setFromValue(0);
    ft.setToValue(1);
    ft.play();
} 

I would like to make a button enabled when all of the groups associated with the validators of these text fields are visible.

I have tried using a BooleanBinding but it does not allow me to bind a boolean value - I have to bind a boolean property.

EDIT: Following is the code that i attempted but came back with an error 'boolean can not be dereferenced'

BooleanBinding accountBind = completeLabel0.isVisible().or(completeLabel1.isVisible());
createButton.disableProperty().bind(accountBind);

Upvotes: 1

Views: 1590

Answers (1)

James_D
James_D

Reputation: 209225

BooleanBinding accountBind = completeLabel0.isVisible().or(completeLabel1.isVisible());
createButton.disableProperty().bind(accountBind);

should be

BooleanBinding accountBind = completeLabel0.visibleProperty().or(completeLabel1.visibleProperty());
createButton.disableProperty().bind(accountBind);

assuming completeLabel0 and completeLabel1 are some kind of node.

Upvotes: 2

Related Questions