以编程方式设置 dock:name Java Mac OS X JVM 属性
是否有编程替代方法来设置 dock:name Java Mac OS X 属性
Is there a programatic alternative to setting the dock:name Java Mac OS X property by doing
java -Xdock:name="My App Name" -jar myapp.jar
,或者这是设置 dock:name 属性的唯一方法?
, or is this the only way to set the dock:name property?
推荐答案
已经有一段时间了,但是我相信您需要执行以下操作(这是假设您使用的是 Swing):
It's been a while, but I believe you need to do the following (this is assuming you're using Swing):
- 将您的
main()
方法放在与 JFrame 不同的类中. - 在创建 JFrame 之前,设置com.apple.mrj.application.apple.menu.about.name"系统属性.
- Put your
main()
method in a separate class from the JFrame. - Before creating the JFrame, set the "com.apple.mrj.application.apple.menu.about.name" system property.
例如:
public class Launcher {
public static void main(String[] args) {
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Hello World!");
JFrame jframe = new MyJFrame();
jframe.setVisible(true);
}
}
相关文章