Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

macos

javafx-2

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 at runtime after the app starts? If it's not possible to change at runtime, is there a way to change it after app restarts? I think that name came from Info.plist. The app is built using JavaFX ant task for Mac OS X.

Thanks.

like image 921
ytw Avatar asked Sep 17 '13 19:09

ytw


2 Answers

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>
like image 132
Tim Büthe Avatar answered Sep 23 '22 19:09

Tim Büthe


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.

like image 39
Jonathon Bell Avatar answered Sep 23 '22 19:09

Jonathon Bell