[threeten-dev] [JavaFX API Review] RT-27841: Define API for DatePicker

Leif Samuelsson leif.samuelsson at oracle.com
Thu Apr 18 15:30:02 PDT 2013


Hi all,

The new JSR-310 API for date and time has now made it into JDK 8. This means
that we can finally add a DatePicker UI control to JavaFX with support for a
large number of locale based calendar formats.

DatePicker is built on ComboBox, using both a TextField and a popup for
typing or picking a date. The value type for setting and getting a date is
java.time.LocalDate. This class uses the ISO-8601 calendar (proleptic
Gregorian), although the actual display of the calendar popup will be based
on whatever calendar (Chronology in the API) that is either specified in the
user's default Locale, or set explicitly by the application.

The DatePicker API is intended to be minimal at first, while still providing
lots of flexibility. We can expand it with various conveniences in the
future after getting it properly road tested. If in the future we get a
FormattedTextField that extends TextField, then we can retrofit it into
DatePicker without losing API compatibility.

The popup can be styled with CSS and the individual grid cells can be fully
customized by use of a cell factory.

The application can add validation and error handling for text input by
providing a StringConverter. This could for example wrap the default
converter and catch parse exceptions.

For reference, here are some links to the java.time Javadoc pages:

http://download.java.net/jdk8/docs/api/java/time/LocalDate.html
http://download.java.net/jdk8/docs/api/java/time/chrono/Chronology.html

Below is a brief overview of the proposed DatePicker and DateCell
classes.  You can find the full Javadoc in the JIRA issue:

https://javafx-jira.kenai.com/browse/RT-27481

---

package javafx.scene.control;

public class DatePicker extends ComboBoxBase<LocalDate> {
     public DatePicker();
     public DatePicker(LocalDate localDate);
     public ObjectProperty<Callback<DatePicker, DateCell>> dayCellFactoryProperty();
     public ObjectProperty<Chronology> chronologyProperty();
     public BooleanProperty showWeekNumbersProperty();
     public ObjectProperty<StringConverter<LocalDate>> converterProperty();
     public ReadOnlyObjectProperty<TextField> editorProperty();
}

---

package javafx.scene.control;

public class DateCell extends Cell<LocalDate> {
     @Override public void updateItem(LocalDate item, boolean empty);
     @Override protected Skin<?> createDefaultSkin();
}

---

A code review for the implementation will follow.

Thanks,
Leif



More information about the threeten-dev mailing list