-
Bug
-
Resolution: Fixed
-
P3
-
8u40
-
x86
-
os_x
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8139461 | 8u72 | Jonathan Giles | P3 | Closed | Fixed | b03 |
FULL PRODUCT VERSION :
$ java -version
java version "1.8.0_60-ea"
Java(TM) SE Runtime Environment (build 1.8.0_60-ea-b23)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b22, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin 14.4.0 Darwin Kernel Version 14.4.0: Thu May 28 11:35:04 PDT 2015; root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
In a UI where a (parent) dialog spawns a child dialog (e.g., parent dialog is a configuration dialog and needs to allow the user to browse for a particular folder as part of that configuration), if the user chooses to exit the child dialog using the ESC keypress, both the child and parent dialogs are closed. This is not expected behavior. The ESC keypress should only affect the child dialog.
This has only been run on OS X (see versions below), so it's not clear that this is a problem across all platforms.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided code and pay attention to the instructions in the UI:
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Pressing ESC to close a dialog, even if it is spawned from another dialog, should only close the current dialog.
ACTUAL -
Pressing ESC to close a dialog spawned from another dialog closes the current dialog and the parent dialog.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/**
* As of at least JDK 1.8.0_60 early releases (maybe earlier, e.g. 1.8.0_40),
* if you launch a dialog (e.g., file/dir chooser from a JavaFX Alert,
* and the user presses ESC to close the dialog, the alert will also close.
*
* This is unexpected behavior.
*
* @author Paul Furbacher
*
*/
public class DemoApp extends Application {
private static final String VBOX_STYLE = "-fx-padding: 12px; -fx-alignment: center";
@Override
public void start(Stage primaryStage) throws Exception {
VBox vbox = new VBox(16);
vbox.setStyle(VBOX_STYLE);
Label label = new Label("Press button to launch dialog");
Button button = new Button("Save ...");
button.setOnAction(ae -> {
createAndShowDirChooser();
});
vbox.getChildren().addAll(label, button);
primaryStage.setScene(new Scene(vbox));
primaryStage.sizeToScene();
primaryStage.show();
}
protected void createAndShowDirChooser() {
Alert alert = new Alert(AlertType.INFORMATION); // or try other types, such as AlertType.CONFIRMATION.
// Except for AlertType.NONE, they all exhibit the problem.
alert.setTitle("Demo Alert");
Button browseButton = new Button("Browse...");
browseButton.setOnAction(ae -> {
DirectoryChooser chooser = new DirectoryChooser();
chooser.showDialog(browseButton.getScene().getWindow());
});
VBox vbox = new VBox(16);
vbox.setStyle(VBOX_STYLE);
vbox.getChildren().addAll(
new Label("Press ESC in the directory chooser.\n\nUnexpected result: this dialog will also close!\n\n"), browseButton);
alert.getDialogPane().setContent(vbox);
Platform.runLater(() -> browseButton.requestFocus());
alert.showAndWait();
}
public static void main(String[] args) {
Application.launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None, except perhaps rewriting the parent view to use a stage instead of an alert (dialog).
$ java -version
java version "1.8.0_60-ea"
Java(TM) SE Runtime Environment (build 1.8.0_60-ea-b23)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b22, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin 14.4.0 Darwin Kernel Version 14.4.0: Thu May 28 11:35:04 PDT 2015; root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
In a UI where a (parent) dialog spawns a child dialog (e.g., parent dialog is a configuration dialog and needs to allow the user to browse for a particular folder as part of that configuration), if the user chooses to exit the child dialog using the ESC keypress, both the child and parent dialogs are closed. This is not expected behavior. The ESC keypress should only affect the child dialog.
This has only been run on OS X (see versions below), so it's not clear that this is a problem across all platforms.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided code and pay attention to the instructions in the UI:
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Pressing ESC to close a dialog, even if it is spawned from another dialog, should only close the current dialog.
ACTUAL -
Pressing ESC to close a dialog spawned from another dialog closes the current dialog and the parent dialog.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/**
* As of at least JDK 1.8.0_60 early releases (maybe earlier, e.g. 1.8.0_40),
* if you launch a dialog (e.g., file/dir chooser from a JavaFX Alert,
* and the user presses ESC to close the dialog, the alert will also close.
*
* This is unexpected behavior.
*
* @author Paul Furbacher
*
*/
public class DemoApp extends Application {
private static final String VBOX_STYLE = "-fx-padding: 12px; -fx-alignment: center";
@Override
public void start(Stage primaryStage) throws Exception {
VBox vbox = new VBox(16);
vbox.setStyle(VBOX_STYLE);
Label label = new Label("Press button to launch dialog");
Button button = new Button("Save ...");
button.setOnAction(ae -> {
createAndShowDirChooser();
});
vbox.getChildren().addAll(label, button);
primaryStage.setScene(new Scene(vbox));
primaryStage.sizeToScene();
primaryStage.show();
}
protected void createAndShowDirChooser() {
Alert alert = new Alert(AlertType.INFORMATION); // or try other types, such as AlertType.CONFIRMATION.
// Except for AlertType.NONE, they all exhibit the problem.
alert.setTitle("Demo Alert");
Button browseButton = new Button("Browse...");
browseButton.setOnAction(ae -> {
DirectoryChooser chooser = new DirectoryChooser();
chooser.showDialog(browseButton.getScene().getWindow());
});
VBox vbox = new VBox(16);
vbox.setStyle(VBOX_STYLE);
vbox.getChildren().addAll(
new Label("Press ESC in the directory chooser.\n\nUnexpected result: this dialog will also close!\n\n"), browseButton);
alert.getDialogPane().setContent(vbox);
Platform.runLater(() -> browseButton.requestFocus());
alert.showAndWait();
}
public static void main(String[] args) {
Application.launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None, except perhaps rewriting the parent view to use a stage instead of an alert (dialog).
- backported by
-
JDK-8139461 Pressing ESC in a nested alert closes self and parent alert
-
- Closed
-
- duplicates
-
JDK-8131980 Dismissing a ContextMenu with Escape Key cancels the Dialog that was showing it.
-
- Closed
-
-
JDK-8132878 [Dialog] Intercepting the Cancel-Button-Action closes confirmation-Dialog automatically
-
- Closed
-
- relates to
-
JDK-8131980 Dismissing a ContextMenu with Escape Key cancels the Dialog that was showing it.
-
- Closed
-