Java JMenuBar Mac example - put the JMenuBar on the Mac OS X menubar

Mac Java menubar FAQ: I'm creating a "Mac Java" application for (a Java Swing application for Mac OS X) ... how do I put my Java menu bar (JMenuBar) on the Mac menubar?

Answer: In your Java Mac application, set the system property apple.laf.useScreenMenuBar to true, like this:

System.setProperty("apple.laf.useScreenMenuBar", "true");

You'll see that this moves the menu bar off of your JFrame and onto the Mac OS X system menu bar. Note that you need to do this very early in your Java application, such as in the main method.

Much more thorough Mac/Java/Swing tutorial

This article discusses one particular problem related to Mac/Java/Swing development. If you want to know all about how to make a Java application look and feel like a native Mac application, please see my Making Java/Swing applications work like native Mac applications tutorial.

Other Mac/Java posts

Besides that longer Mac/Java tutorial, I also have these shorter Mac Java tutorials: