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

Default button still receives onAction events after being removed from scene graph

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • 8
    • 7u25
    • javafx
    • None
    • Windows 7 64bit, JDK 7u25

      A default button receives onAction events triggered by pressing the Enter key when it has been removed from the scene graph.

      This issue is very similar to https://javafx-jira.kenai.com/browse/RT-22106 but here the button is not removed from its parent's children list. Instead, the parent is removed from the scene.

      Run the following code to reproduce the issue:

      StackPane root = new StackPane();
      Button btn = new Button("Default Button");
      btn.setDefaultButton(true);
      btn.setOnAction(new EventHandler<ActionEvent>() {
         @Override
         public void handle(final ActionEvent event) {
            System.out.println("DefaultButton");
         }
      });
      root.getChildren().add(btn);

      Scene scene = new Scene(root, 400, 400);
      primaryStage.setScene(scene);
      primaryStage.show();

      StackPane root2 = new StackPane();
      root2.getChildren().add(new TextField());
      scene.setRoot(root2);


      The problem does not occur with the latest Java 8 EA build, btw.

            miflemi Mick Fleming
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: