Okay, so I've done Swing applications before, and I know if you want to display a different name for the application menu (the one on Macs that usually have a "Preferences" and "Quit" option), you have to use: System.setProperty("com.apple.mrj.application.apple.menu.about.name", "App name");
and it must be executed before the JFrame is created. I've done this, but it continues to show my Main class' name as the menu name, as if I didn't write that line of code at all. I googled for this issue, but couldn't find anything useful, and then I just searched on here, but everyone who had a similar issue was running Java 1.5, 1.6, or 1.7. So I thought maybe it had something to do with my current Java version, 1.8.
This, this, and this did not work. This, this, and this either sent me to outdated info, or the links didn't work anymore. Also, I'm running Mac 10.8.
Any suggestions/answers would be greatly appreciated.
An update:
here is the code I originally had:
package bouncing_off_axes;
/**
* This is the driver class of this program.
*
* @author Mason
*
*/
public class Main {
/**
* The driving method.
*
* @param args
*/
public static void main(String[] args) {
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Physics Engine Practice - Bouncing Balls");
SimulationController view = new SimulationController("Test");
}
}
And here is a solution that trashgod provided to someone else:
package bouncing_off_axes;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
/** @see https://stackoverflow.com/questions/8955638 */
public class NewMain {
public static void main(String[] args) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty(
"com.apple.mrj.application.apple.menu.about.name", "Name");
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("Gabby");
final JPanel dm = new JPanel() {
@Override
public Dimension getPreferredSize() {
return new Dimension(320, 240);
}
};
dm.setBorder(BorderFactory.createLineBorder(Color.blue, 10));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(dm);
frame.pack();
frame.setLocationByPlatform(true);
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
menuBar.add(fileMenu);
frame.setJMenuBar(menuBar);
frame.setVisible(true);
}
});
}
}
And apparently I need 10 reputation to post images, so I can't show you the result, but it didn't work out.
package bouncing_off_axes
in the code. It did not work, the menu continued to display the class name and not the name that was set. I'll edit my post and put what I originally had and the example you provided. Also, I'd like to make this change in the code, and not on the command line. – StallfeedsetProperty()
approach fails with Java 8. Why not add your JAR to an application bundle, for example? – Wounded