Change the application name at runtime on Mac for a JavaFX-based App

后端 未结 4 1736
遇见更好的自我
遇见更好的自我 2021-01-06 03:08

Please take a look at this image: http://i.imgur.com/pHIg1AA.png Is it possible to change the application name (\"My JavaFX-based Mac App\") in the Mac OS X system menu bar

相关标签:
4条回答
  • 2021-01-06 03:41

    When using javafx-maven-plugin you can specify it in your pom.xml like this:

    <plugin>
      <groupId>com.zenjava</groupId>
      <artifactId>javafx-maven-plugin</artifactId>
      <version>8.6.0</version>
      <configuration>
        <appName>Aaa Working Title</appName>
        ...
      </configuration>
      ...
    </plugin>
    
    0 讨论(0)
  • 2021-01-06 03:43

    I'm aware of two methods of achieving what you want:

    1) Call javafx.awt.Desktop.getDesktop from the main thread before creating any stages:

    object MYAPP
    {
      def main(args: Array[String]) =
      {
        val d = java.awt.Desktop.getDesktop
    
        // ...optionally, add handlers for interesting desktop events
    
        javafx.application.Application.launch(classOf[MyApp], args: _*)
      }
    }
    

    I believe, among other things, this renames the application menu to MYAPP.

    2) Package your application using the javapackager tool.

    0 讨论(0)
  • 2021-01-06 03:44

    That should work as is always worked for me :D

    primaryStage.setTitle("LOLOLOLOL");

    This changes your window's name. You can change this value at any time, if you have the Stage element at your disposal.

    0 讨论(0)
  • 2021-01-06 04:02

    Actually, you can change it very easily by using the java-command args
    -Xdock:name=SomeName

    This works fine for me, launching a JavaFX application on a Java11 custom-built runtime with a bash-script as a native application.

    From the Oracles Java 10 documentation:

    -Xdock:name=application name
    Overrides the default application name displayed in dock. [*]

    -Xdock:icon=path to icon file
    Overrides the default icon displayed in dock.

    [*] Also affects the menu name.

    You can see my complete command by looking for 'src_macos/tmpl/George.sh' here: https://bitbucket.org/andante-george/george-application/src

    For the About-dialog simply do do: java.awt.Desktop.getDesktop().setAboutHandler(my_about_handler). In your handler open whatever kind of dialog or window you want.

    0 讨论(0)
提交回复
热议问题