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

Add API to set the application name

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      When we run JavaFX application we need to set its name that will be displayed in the top bar. However, the only solution that allows to do it is possible only with using of internal classes:

      import java.io.ByteArrayInputStream;
      import java.util.Base64;
      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class Test extends Application {

          @Override
          public void start(Stage primaryStage) {
              Button btn = new Button();
              btn.setText("Say 'Hello World'");
              btn.setOnAction(new EventHandler<ActionEvent>() {

                  @Override
                  public void handle(ActionEvent event) {
                      Test __app = new Test();
                      Stage __stage = new Stage();
                      __app.start(__stage);
                  }
              });

              StackPane root = new StackPane();
              root.getChildren().add(btn);
              Scene scene = new Scene(root, 300, 250);
              primaryStage.setTitle("Hello World!");
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              com.sun.javafx.application.LauncherImpl.launchApplication(Test.class, TestPre.class, args);
          }
      }

      That solution was taken from SO: https://stackoverflow.com/a/54467323/5057736. Although this solution works it uses internal classes that is very bad from all point of views and particularly with using JPMS.

      So, I suggest to make API for setting GNOME application name public in order not to use internal classes.


            kcr Kevin Rushforth
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: