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

Enter button inconsistency in a Confirmation dialog

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10
      Java 11.0.4

      A DESCRIPTION OF THE PROBLEM :
      On Windows, if you have a confirmation dialog with a CheckBox as it's content:
      If you click on the checkbox and then hit enter, the checkbox is checked rather than the confirmation dialog closing.
      This seems to be a regression from Java 1.8 where it would close the confirmation dialog.

      Note also that the Mac doesn't suffer from this same behaviour.

      REGRESSION : Last worked in version 11

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached example source code
      Select the checkbox
      Hit Enter
      Notice that the dialog doesn't close

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The dialog should close after hitting the enter key
      ACTUAL -
      The dialog stays open and the checkbox is ticked instead

      ---------- BEGIN SOURCE ----------
      import java.util.Optional;

      import javafx.application.Application;
      import javafx.scene.control.Alert;
      import javafx.scene.control.Alert.AlertType;
      import javafx.scene.control.ButtonType;
      import javafx.scene.control.CheckBox;
      import javafx.stage.Stage;

      public class HelloWorld extends Application
      {
          public static void main(
              String[] args)
          {
              launch(args);
          }

          @Override
          public void start(
              Stage primaryStage)
          {
              showDialog();
          }
          
          private void showDialog()
          {
              Alert alert = new Alert(AlertType.CONFIRMATION);
              alert.setTitle("Confirmation Dialog");
              alert.setHeaderText("Look, a Confirmation Dialog");
              alert.setContentText("Are you ok with this?");
              alert.getDialogPane().setContent(new CheckBox());

              
              Optional<ButtonType> result = alert.showAndWait();
              if (result.get() == ButtonType.OK)
              {
                  System.out.println("OK");
              }
              else
              {
                  System.out.println("Cancel");
              }
          }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              aghaisas Ajit Ghaisas
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: