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

DatePicker throws uncatchable exception on tab out from garbled text

    XMLWordPrintable

Details

    • b18
    • generic
    • generic

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10 pro. Attached example run in IntelliJ.

      A DESCRIPTION OF THE PROBLEM :
      If a user mistypes a date then tabs out the date text is left as is but a DateTimeParseException is thrown. The exception is thrown from a 'lost focus' event handler declared in the DatePicker constructor and so cannot be caught by any obvious mechanism.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use attached trivial code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Handling should be as for pressing Enter with a garbled text - restore last good value and, ideally, leave the cursor on the date field.
      ACTUAL -
      Uncatchable DateTimeParseException exception is thrown

      ---------- BEGIN SOURCE ----------
      package com.example.demo;

      import javafx.application.Application;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.control.DatePicker;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      import java.io.IOException;
      import java.time.LocalDate;

      public class HelloApplication extends Application
      {
          @Override
          public void start(Stage stage) throws IOException
          {
              Group root = new Group();
              VBox vbox = new VBox(8);
              vbox.getChildren().addAll(new DatePicker(LocalDate.now()), new TextField());
              root.getChildren().add(vbox);
              Scene scene = new Scene(root, 200, 150);
              stage.setTitle("Hello!");
              stage.setScene(scene);
              stage.show();
          }

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

      CUSTOMER SUBMITTED WORKAROUND :
      None known.

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              angorya Andy Goryachev
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: