JDK-8149622 : ComboBox produces unexpected event behaviour when ENTER key is pressed
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u74
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2016-02-10
  • Updated: 2019-10-01
  • Resolved: 2016-06-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Fixed
Related Reports
Relates :  
Relates :  
Relates :  
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 ----------


Comments
Changeset: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/8e89d319dce2
28-06-2016