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.
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.
- duplicates
-
JDK-8115869 CancelButton, Button with setCancelButton(true), still works when it's parent Node is removed from the scene or when it's parent Node is being hidden
-
- Closed
-
-
JDK-8127304 Ensemble: Stage has open problem
-
- Closed
-