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

[Dialogs] Dialogs aren't centered on Windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 8u20
    • javafx
    • None
    • Windows 7, JDK 8u20, openjfx-dialogs-1.0.2

      Dialogs on Windows aren't shown in the center of the screen. The native behavior on Windows is to open dialogs in the middle.

      public class DialogDemo extends Application {
          @Override
          public void start(Stage primaryStage) throws Exception {
              Button button = new Button("Show Dialog");
              button.setOnAction(event -> {
                  Alert alert = new Alert(Alert.AlertType.ERROR);
                  alert.initOwner(primaryStage);
                  
                  // workaround
                  // alert.getDialogPane().getScene().getWindow().centerOnScreen();
                  
                  alert.setContentText("Message");
                  alert.setHeaderText("Header");
                  alert.setTitle("Title");
                  alert.showAndWait();
              });

              BorderPane root = new BorderPane();
              root.setCenter(button);
               
              Scene scene = new Scene(root, 300, 300);
              primaryStage.setScene(scene);

              primaryStage.show();
          }
      }

            jgiles Jonathan Giles
            kacperjfx Kacper (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: