Native Swing Menu Bar Support For MacOS X In Java
Solution 1:
@Kezzer
I think I see what's going on. If you put the main() method in a different class, then everything works. So you need something like:
public class RootGUILauncher {
public static void main(String[] args) {
try {
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Test");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(ClassNotFoundException e) {
System.out.println("ClassNotFoundException: " + e.getMessage());
}
catch(InstantiationException e) {
System.out.println("InstantiationException: " + e.getMessage());
}
catch(IllegalAccessException e) {
System.out.println("IllegalAccessException: " + e.getMessage());
}
catch(UnsupportedLookAndFeelException e) {
System.out.println("UnsupportedLookAndFeelException: " + e.getMessage());
}
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
new RootGUI();
}
});
}
And then put your RootGUI class in a different file.
Solution 2:
You need to set the "com.apple.mrj.application.apple.menu.about.name" system property in the main thread, not in the Swing thread (in other words, just make it the first line in the program).
Solution 3:
As I understand you want to rename your application menu shown on the os x menu bar. Well, I didn't find a system property but I found a command line option:
-Xdock:name="YourNameHere"
that worked for me.
BTW: The syystem property com.apple.mrj.application.apple.menu.about.name is for renaming the about menu item in your application menu, not the menu bar itself
See this link here (the old link was probably killed sometime after the sun-oracle-aquisition).
Solution 4:
You can also use Macify when you build the app so you don't need to change any code.