JFXtras Calendar Picker

266 views Asked by At

I would like some samples of code to start using jfxtras calendarpicker, please. I am writing a JavaFX app scheduler. I need to select multiple dates into an array or list, and would like to keep the calendar open while a user selects and deselects dates. Datepicker closes annoyingly after a selection, and I cannot extend the code to stop it as methods and fields are private :-( The selections may need to be highlighted in different colors depending on type of selection. The jfxtras calendarpicker looks ideal :-) I downloaded the jfxtras-icalendarfx-15-r2. jar from https://search.maven.org/search?q=g:org.jfxtras I have read the javadoc, but would like some simple samples to start.

1

There are 1 answers

0
tbeernot On

I don't think there is too much to put in examples; you just create the control add add it to a Pane. If you set

calendarPicker.setMode(CalendarPicker.Mode.MULTIPLE)

then you allow multiple calendars to be selected, which are available in the collection

calendarPicker.calendars()

And that basically is it. As the javadoc describes, you can prevent days from being selected using disabledCalenders, or highlight some using highlightedCalendars, both can be repopulated when the displayed range changes using setCalendarRangeCallback. And that is about it. It does not support different kinds of highlight, but I figure you can use CSS to do something with that. Not sure what your requirements are.

You can take a peek at the tests

https://github.com/JFXtras/jfxtras/blob/11/jfxtras-controls/src/test/java/jfxtras/scene/control/test/CalendarPickerTest.java

I would suggest looking at LocalDatePicker or LocalDateTimePicker instead of Calendar though. Same functionality but using the new DateTime API.

And alternative would be JFXtras agenda. http://jfxtras.org/overview.html