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

[Dialog] Dialog does show application icon in title bar

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u40
    • 8u40
    • javafx
    • None
    • Windows x64, Java 8.0_u40_b7
      java.version: 1.8.0_40-ea
      java.vm.version: 25.40-b11

      When a dialog is created using, for instance, Alert#showAndWait() it has an empty icon in the title. it should have the same icon as the application that it is running from. Here is an example code:

      public class DialogDemo extends Application {
          @Override
          public void start(Stage primaryStage) throws Exception {

              Image image = new Image("icon.png");
              primaryStage.getIcons().add(image);

              Button button = new Button("Show Dialog");
              button.setOnAction(event -> {
                  Alert alert = new Alert(Alert.AlertType.ERROR);
                  alert.initOwner(primaryStage);
                  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
            duke J. Duke
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: