I'm trying to learn a sprinkling of JavaFx to
test the backend code of a personal project I am working on. At the moment I am trying to create a simple login dialog. I want to disable the 'ok' button until all the input fields contain valid data. I have knocked together a little example to demonstrate what I want.
For context, this is how I create the dialog:
and this is the fxml:
My issue is enabling the button once the input it valid. I have another method 'validateInput()' to check if the TextField contains valid data.
I tried creating a field for the DialogPane, but calling lookUpButton(ButtonType.OK) always returns null. I also tried using a Dialog<ButtonType> field and then setting it to the Dialog object I create in buttonClicked(), instead of a local variable:
The field is always null from the validateInput() method, however.
I'm more or less shooting in the dark here. There is a lot to JavaFx which I will have to get to grips with
How can I enable the button from the validateInput() method?