Last updated October 03, 2009 06:09, by tbee

JavaFX Calendar (Date) Picker

As of 2009-10-01 JFXCalendarPicker has been moved into the JFXtras project.


This is a 100% in JavaFX written DatePicker (or better CalendarPicker) component. It allows selecting single, ranges or multiple dates, depending on the mode it is in. Below are screenshots of the picker with the default "Standard" skin using the Caspian scheme:

Single:


Range:


Multiple:


The picker is multilanguage:


There is also an gray scheme for this skin:

On this skin I also use the "Nudger" component (part of the CalendarPicker, visible at the top left and right corner); it's a spinner component that can be restricted to a sequence. By either clicking, using the mousewheel or dragging the mouse left or right over the Nudger, it increases or decreases the counter. The month-nudger is limited to 12 months, the year nudger is unlimited.

The first skin was one using standard JavaFX controls. But JavaFX 1.2 does not have a ComboBox yet, so I graciously used Rakesh Menon's one for the months until the time that JavaFX has one included.

The usage of the component is rather simple:

   CalendarPicker { }

or:

   CalendarPicker {  calendar: new GregorianCalendar(2009, 7, 30) }

or:

   CalendarPicker {  locale: Locale.FRENCH }

or:

   CalendarPicker {  mode: CalendarPicker.MODE_MULTIPLE }


Or any combination of these naturally. The calendar and calendars variables hold the active and selected dates.

The locale only determines the language that is used, settings like "first day of week" are provided by the calendar object. So it is possible to have english calendar settings (e.g. first day of week is Sunday) with french texts (in France the first day of the week is Monday). In order to have both values in the same locale, one needs to use the locale aware factory method of Calendar:

  java.util.Calendar.getInstance(Locale)


Demonstrations are available at: appletwebstart

  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20100521.d19488a)
 
 
loading
Please Confirm