2

When I try to add a JMenuBar to my frame in Mac, it doesn't show up. I assume it's because JMenuBar isn't integrated into the Mac native method. So can anybody help me with the code that I can use to make my bar viewable?

Shawn Shroyer
  • 901
  • 1
  • 8
  • 18
  • The menu bar should appear in the frame, until you set `useScreenMenuBar` using any of the approaches suggested. This [example](http://stackoverflow.com/a/4039359/230513) may help clarify exactly what isn't showing up where. – trashgod Apr 02 '12 at 10:20

3 Answers3

4

Firstly it you need to tell the JVM to use the MenuBar like:

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

Then in your JFrame set the menu bar like so:

frame.setJMenuBar(new MenuBar());
Dean
  • 8,668
  • 17
  • 57
  • 86
3

Add the following VM argument to the java call:

-Dapple.laf.useScreenMenuBar=true
Guillaume Polet
  • 47,259
  • 4
  • 83
  • 117
3

You can also set the apple.laf.useScreenMenuBar property to true in your Info.plist, as shown here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045