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?
Asked
Active
Viewed 194 times
2
-
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 Answers
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
-
Instead of new MenuBar() place what your JMenuBar is called. And are you using the java version supplied by apple? – Dean Apr 01 '12 at 23:18
-
I know. I'm no noob at java; I just converted to Mac a week ago. And yeah, I am. – Shawn Shroyer Apr 01 '12 at 23:25
3
Add the following VM argument to the java call:
-Dapple.laf.useScreenMenuBar=true

Guillaume Polet
- 47,259
- 4
- 83
- 117