JFXtras - How to add Change Listener to CalendarTextField?


how can I listen to a change in the CalendarTextField in JFXtras? For example a new choosen date from the picker-menu or a typed-in date?

    date.addEventFilter(MouseEvent.ANY, new EventHandler<Event>() {

        public void handle(Event arg0) {


gives me every movement of the mouse within the field. I didn't find another eventType that makes sense.

I also thought about adding this event filter in the window and check the selected date at every click in the window. But that can't be the right way.

6/11/2013 7:56:30 AM

Alright, found it here:

    date.valueProperty().addListener(new ChangeListener<Calendar>() {
        public void changed(
                ObservableValue<? extends Calendar> observableValue,
                Calendar oldValue, Calendar newValue) {
            System.out.println(oldValue + " -> " + newValue);

I didn't realize that in FX a listener has to be set to the property, not to the component like in Swing.

6/11/2013 9:34:11 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow