• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

How can I enable a Dialog's button from an event handler method?

 
Master Rancher
Posts: 170
24
Firefox Browser MySQL Database Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic