0

In my JavaFX project, I'm including a controlsFX Wizard using Linear.Flow. For one of my WizardPane's, I would like the Next button's disabled property to be bound to a boolean property. (More specifically, if a TextField is empty, the button should be disabled).

However, I am unable to find any solution which does so. (The possible solutions provided here do not work for me).

Here is my WizardPane:

private WizardPane getName() {
    TextField textField = new TextField();
    textField.requestFocus();

    final WizardPane namePane = new WizardPane();

    namePane.setHeaderText("Choose Name for File");

    final GridPane grid = new GridPane();

    grid.add(new Label("File Name:"), 0, 0);
    grid.add(textField, 1, 0);

    namePane.setContent(grid);

    return namePane;
}

My unsuccessful attempt to bind the disablede property is as follows:

@Override
public void onEnteringPage(Wizard wizard) {
    this.getButtonTypes()
                .stream()
                .filter(type -> type.getButtonData().equals(ButtonBar.ButtonData.NEXT_FORWARD))
                .map(this::lookupButton)
                .findFirst()
                .ifPresent(next -> next.disableProperty().bind(textField.textProperty().isEmpty()));
}

Any suggestions much appreciated. Thanks!

1 Answers1

5

Turns out I really overcomplicated it. The solution is simply to bind the Wizard's invalidProperty:

Wizard wiz = new Wizard();
wiz.invalidProperty().bind(textField.textProperty().isEmpty());