The following code demonstrates the bug. Run the code. Click in the button in the window and a confirmation alert appears. Click in either button of the alert and an error alert appears. Now click OK in the error alert to dismiss it (and the confirmation alert). When you do so, a beep is sounded, as if you had attempted to click in a window covered by the modal alert dialog. I cannot reproduce this bug on Windows 7 x64 Service Pack 1 and so it seems to be Mac-specific.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.stage.Stage;
public class ModalDialogExample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Button button = new Button("Press me");
button.setOnAction(event -> {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setOnCloseRequest(event1 -> {
Alert alert1 = new Alert(Alert.AlertType.ERROR);
alert1.showAndWait();
});
alert.showAndWait();
});
Scene scene = new Scene(button, 100, 100);
primaryStage.setScene(scene);
primaryStage.setTitle("ModalDialogExample");
primaryStage.show();
}
}
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.stage.Stage;
public class ModalDialogExample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Button button = new Button("Press me");
button.setOnAction(event -> {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setOnCloseRequest(event1 -> {
Alert alert1 = new Alert(Alert.AlertType.ERROR);
alert1.showAndWait();
});
alert.showAndWait();
});
Scene scene = new Scene(button, 100, 100);
primaryStage.setScene(scene);
primaryStage.setTitle("ModalDialogExample");
primaryStage.show();
}
}
- duplicates
-
JDK-8097090 With two or more application modal windows; windows deeper in the stack are receiving requestToFront when not enabled causes an NSBeep.
- Resolved
-
JDK-8129581 [Mac] Child modal windows may beep when closing
- Closed