Swing application menu name not displaying correctly in Java 1.8

前端 未结 1 394
無奈伤痛
無奈伤痛 2021-01-13 07:50

Okay, so I\'ve done Swing applications before, and I know if you want to display a different name for the application menu (the one on Macs that usually have a \"Preferences

相关标签:
1条回答
  • 2021-01-13 08:31

    Using Java 8 on Mac OS X 10.9, setting the System property

    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Name");
    

    appears to be ineffectual in changing the name displayed in the application menu. Alternatives that still work include these:

    • By default, the application menu will display the simple name of the class specified in the java command line or the Main-Class attribute of the JAR's manifest.

       java -cp build/classes mypackage.Name
       java -jar dist/MyJar.jar
      
    • Use the -Xdock:name="Name" command line parameter.

      java -Xdock:name="Name" -cp build/classes mypackage.Main
      java -Xdock:name="Name" -jar MyJar.jar
      
    • Add the application JAR to a Mac application bundle, as shown here, an add the attribute to the Info.plist.

      <key>JVMOptions</key>
      <string>-Xdock:name=Name</string>
      
    0 讨论(0)
提交回复
热议问题