Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java OS X Lion Set application name doesn't work

Tags:

java

macos

swing

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?

like image 845
aleroot Avatar asked Jan 18 '12 23:01

aleroot


Video Answer


1 Answers

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

like image 128
andrewdotn Avatar answered Sep 22 '22 17:09

andrewdotn