-
CSR
-
Resolution: Approved
-
P3
-
None
-
source, binary
-
minimal
-
This adds two new new methods similar to the ComboBox class, and fixes a behavioral anomaly in the user interface as a result. There is a small chance that some users could be relying on the existing behavior.
-
Java API
-
JDK
Summary
Add the methods commitValue and cancelEdit to the DatePicker class to provide methods which will either commit the value in the DatePicker TextField (set the text as value) or cancel it (set the text based off the value).
Problem
In https://bugs.openjdk.java.net/browse/JDK-8150946, two new methods were added to ComboBox like controls with a TextField (ComboBox, Spinner): The commitValue and cancelEdit method. Those two method were simply forgotten for the DatePicker, so therefore there is currently no way to commit/cancel a value written in the DatePicker TextField. This also caused a regression, which can be fixed via the proposed api.
Solution
The proposed solution is to add the same two method to the DatePicker class as well (which is in fact also a ComboBox like control with a TextField). Also a lot of new testcases will be added to test this solution.
Specification
The following two method will be added to the DatePicker. They are semantically the same as in ComboBox and Spinner
/**
* If the {@link DatePicker} is {@link #editableProperty() editable}, calling this method will attempt to
* commit the current text and convert it to a {@link #valueProperty() value}.
* @since 18
*/
public final void commitValue() {
...
}
/**
* If the {@link DatePicker} is {@link #editableProperty() editable}, calling this method will attempt to
* replace the editor text with the last committed {@link #valueProperty() value}.
* @since 18
*/
public final void cancelEdit() {
...
}
- csr of
-
JDK-8191995 Regression: DatePicker must commit on focusLost
- Resolved