RFR: 5032471: JFormattedTextField does not use editformatter on initial focus with setText()
Abhishek Kumar
abhiscxk at openjdk.org
Tue Jul 25 09:08:44 UTC 2023
On Mon, 24 Jul 2023 09:20:44 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
> When a JFormattedTextField field value is set by setText, then when the field initially gains focus it seems to not use the edit formatter, but rather use display formatter, which is wrong.
> Native "Date and Time setting" in windows changes the date field to edit mode in initial focus itself.
> Fix is made to treat setText as in edit mode and commit the changes made to it.
src/java.desktop/share/classes/javax/swing/JFormattedTextField.java line 747:
> 745:
> 746: @Override
> 747: public void setText(String text){
Suggestion:
public void setText(String text) {
src/java.desktop/share/classes/javax/swing/JFormattedTextField.java line 749:
> 747: public void setText(String text){
> 748: super.setText(text);
> 749: if(isEdited() && isEditValid()){
Suggestion:
if (isEdited() && isEditValid()) {
src/java.desktop/share/classes/javax/swing/JFormattedTextField.java line 750:
> 748: super.setText(text);
> 749: if(isEdited() && isEditValid()){
> 750: try{
Suggestion:
try {
src/java.desktop/share/classes/javax/swing/JFormattedTextField.java line 752:
> 750: try{
> 751: commitEdit();
> 752: } catch(ParseException pe){}//do nothing, we assume this will never happen.
Suggestion:
} catch (ParseException pe){} //do nothing, we assume this will never happen.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14993#discussion_r1273228712
PR Review Comment: https://git.openjdk.org/jdk/pull/14993#discussion_r1273229039
PR Review Comment: https://git.openjdk.org/jdk/pull/14993#discussion_r1273229529
PR Review Comment: https://git.openjdk.org/jdk/pull/14993#discussion_r1273230054
More information about the client-libs-dev
mailing list