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

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P3
    • 8
    • Affects Version/s: 7u25
    • Component/s: javafx
    • None
    • Environment:

      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.

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

              Created:
              Updated:
              Resolved:
              Imported: