I have a CalendarPicker with an EventFilter. In the EventFilter I want the displayedCalendar with CalendarPicker.getDisplayedCalendar(), but I get the wrong date. It is the last date before CalendarPicker update the displayedCalendar.
It seems that my EventFilter is executed before the standard events of the CalendarPicker.
And I cannot use an EventHandler because the event is consumed by CalendarPicker.
For example:
- I see March 2015 in CalendarPicker.
- change the month to April 2015
- in my CalendarPiker.addEventFilter() I get with CalendarPicker.getDisplayedCalendar() "2015-03-01"
- the CalendarPicker shows April 2015
How can I execute the standard Events before my EventFilter?
Here is some code:
calendarpicker.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
if (event.getButton().equals(MouseButton.PRIMARY)) {
Calendar cal = calendarpicker.getCalendar();
if (cal != null) {
selectedDate = cal.getTime();
log.debug(String.format("(selectedDate): %s" , selectedDate));
log.debug(String.format("(displayed): %s" , calendarpicker.getDisplayedCalendar().getTime()));
}
}
}
});
If I pick a date in the calendarpicker, everything is o.k.
The selectedDate is the picked date and displayed calendar is the 1th day of the displayed month.
If I use the spinner to change the month or the year, the selectedDate do not change (I think this is correct because I do not select one date), but the displayed date is the 1th date of the month before I changed the month (e.g. change from april to march => 01.04.2015 instead of 01.03.2015).