简体   繁体   English

自定义OSX Java Swing应用程序的“关于”对话框

[英]Customizing “About” dialog for OSX Java Swing application

I want to customize the "About" dialog box that OSX displays for my Swing application. 我想自定义OSX为我的Swing应用程序显示的“关于”对话框。

When OSX runs a Swing application, it displays a menu on the menu bar named after the main class being run. 当OSX运行Swing应用程序时,它会在菜单栏上显示一个菜单栏,该菜单以运行的主类命名。 To customize this behavior, and display the application's name, the following seems to be the usual course of action: 要自定义此行为并显示应用程序的名称,以下似乎是通常的操作过程:

System.setProperty("com.apple.mrj.application.apple.menu.about.name", "My Swing App");

This approach works. 这种方法有效。 When you then select "My Swing App" > "About My Swing App" from the menu, an About dialog appears. 当您从菜单中选择“我的Swing应用程序”>“关于我的Swing应用程序”时,将出现“关于”对话框。 Unfortunately, the About dialog looks hideous. 不幸的是,关于对话框看起来很可怕。 It contains a default icon, and a version number. 它包含默认图标和版本号。 The version number is always 1.0. 版本号始终为1.0。

How do I change the version number? 如何更改版本号? How do I change the text? 如何更改文字? How do I change the icon? 如何更改图标? Where did the first person who used this strategy find instructions on using " com.apple.mrj.application.apple.menu.about.name "? 使用此策略的第一个人在哪里找到使用“ com.apple.mrj.application.apple.menu.about.name ”的说明? Is there a list somewhere of other properties I can use? 我可以使用其他属性的某个列表吗?

You can implement the menu using OSXAdapter . 您可以使用OSXAdapter实现菜单。 It will get the version number from your Info.plist , as shown in this example . 它将从Info.plist获取版本号,如本所示。

Addendum: Is there a list somewhere of other properties I can use? 附录: 我可以使用其他属性的某个列表吗?

Yes, About Info.plist Keys is fairly recent; 是的, 关于Info.plist Keys是最近的; CFBundleVersion is the one required. CFBundleVersion是必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM