JavaFX how to edit a DatePicker make changing the DatePicker Value?

1.2k Views Asked by At

I have a DatePicker and an OnAction Handler that perform different works depending on the value of the DatePicker,the date I have to enter is a birthday date and I have to make some work if it is a date of birth of an adult and some other work if it is a date of birth of an underage. When I change the date using the "Date Picker Menu" my handler correctly perform the work i need , but when i edit TextField the handler not even reacts like DatePicker doesn't acknowledge of this change. How can i make DatePicker "listening" to edit date using TextField?

1

There are 1 best solutions below

0
Dmytro Maslenko On BEST ANSWER

You can listen to an editor of your DatePicker object:

myDatePicker.getEditor().textProperty().addListener((observable, oldValue, newValue) -> {
    // do something
});

Note, it will be triggered on each typed symbol.