Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
736 views
in Technique[技术] by (71.8m points)

macos - Java OS X Lion Set application name doesn't work

I'm trying to change the application name displayed into the menu bar of OS X but i can't succeed with that. I have tried settings as the first statement in the main method with the following code :

System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Alessio");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

but it doesn't work, in the menu bar is displayed main :

ScreenShot

I'm on Mac OS X Lion (10.7.2).

Is there a way to change the application name in the menu bar? If so, how?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Using JDK8, you can set the apple.awt.application.name property to affect the Application menu name.

However, Martijn Courteaux’s warning still applies: you must do this before any AWT classes are loaded. And AWT classes will be loaded before your main() method runs if it lives in a subclass of JFrame.

Reference:

http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/5c1d06cd7d7b/src/macosx/native/sun/osxapp/NSApplicationAWT.m#l157


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...