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

ComboBox produces unexpected event behaviour when ENTER key is pressed

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u74
    • Fix Version/s: 9
    • Component/s: javafx
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

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


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      When a ComboBox has the focus and the ENTER key is pressed,
      the event bubbling doesn't work as expected.

      Expected behaviour is that EventFilters are called from Top to Bottom starting at the scene. After that EventHandlers are called from Bottom to Top.

      Expected sequence:
      - scene filter
      - combobox filter
      - combobox handler
      - scene handler

      When ENTER key is pressed, the event filter and handler on the scene is called a second time.

      observed sequence:
      - scene filter
      - combobox filter
      - scene filter
      - scene handler
      - combobox handler




      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. execute the provided example programm
      2. make sure the combobox has the focus.
      3. press ENTER key

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      following lines are printed:

      scene filter
      combobox filter
      combobox handler
      scene handler
      ACTUAL -
      following lines are printed:

      scene filter
      combobox filter
      scene filter
      scene handler
      combobox handler

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.ComboBox;
      import javafx.scene.input.KeyEvent;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class Testpp extends Application {

          public static void main(String... args) {
              launch(args);
          }
          
          @Override
          public void start(Stage primaryStage) throws Exception {
              ComboBox<String> cb = new ComboBox<>();
              cb.getItems().addAll("Test", "hello", "world");

              
              cb.addEventFilter(KeyEvent.KEY_RELEASED, event -> System.out.println("combobox filter"));
              cb.addEventHandler(KeyEvent.KEY_RELEASED, event -> System.out.println("combobox handler"));
              
              VBox root = new VBox(cb);

              Scene scene = new Scene(root);

              scene.addEventFilter(KeyEvent.KEY_RELEASED, event -> System.out.println("scene filter"));
              scene.addEventHandler(KeyEvent.KEY_RELEASED, event -> System.out.println("scene handler"));

              primaryStage.setScene(scene);
              primaryStage.show();
          }
      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jgiles Jonathan Giles
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: