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
  • 881
  • 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,110
  • 17
  • 54
  • 85
3

Add the following VM argument to the java call:

-Dapple.laf.useScreenMenuBar=true
Guillaume Polet
  • 46,469
  • 4
  • 81
  • 115
3

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

Community
  • 1
  • 1
trashgod
  • 200,320
  • 28
  • 229
  • 974