Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8196837

Wrong caret position in FX DatePicker.

XMLWordPrintable

    • generic
    • generic

      FULL PRODUCT VERSION :
      java version "1.8.0_112"
      Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Versión 10.0.15063]

      A DESCRIPTION OF THE PROBLEM :
      When you select a date with the format: dd/mm/yyyy or mm/dd/yyyy in the DatePicker's PopUp, and then click on the fourth position of the editor: dd/m(here)m/yyyy or mm/d(here)d/yyyy, and finally press the "delete" key the caret is placed in an incorrect position.

      REGRESSION. Last worked in version 8u151

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_112"
      Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run DatePickerTest.
      Open the DatePicker popUp.
      Select a date "dd/mm/yyyy" or "mm/dd/yyyy".
      Click on the fourth position of the editor: dd/m(here)m/yyyy or mm/d(here)d/yyyy
      Press the delete key.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The caret located in the fourth position: dd/m(here)/yyyy or mm/d(here)/yyyy
      ACTUAL -
      The caret located in the third position. dd/(here)m/yyyy or mm/(here)d/yyyy

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.DatePicker;
      import javafx.scene.layout.GridPane;
      import javafx.stage.Stage;

      public class DatePickerTest extends Application {

          @Override
          public void start(final Stage primaryStage) {

              final GridPane gridPane = new GridPane();

              final DatePicker datePicker = new DatePicker();

              gridPane.add(datePicker, 0, 0);

              final Scene scene = new Scene(gridPane, 700, 700);
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          public static void main(final String[] args) {
              launch(args);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      datePicker.getEditor().skinProperty().addListener(e -> {
          final TextFieldSkin skin = (TextFieldSkin) datePicker.getEditor().getSkin();
          skin.forwardBiasProperty().addListener((ov, o, n) -> {
              skin.setForwardBias(true);
          });
      });


            kcr Kevin Rushforth
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: