In the Java Desktop Application template used by Netbeans, a menu bar is created with JMenuBar and JMenuItems.
How can I get that bar displayed at the top, where menu bars are displayed in MacOSX instead of in-window, like in Windows?
By adding something like this into your code:
if (System.getProperty("os.name").contains("Mac")) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
}
I had the same issue, but I realized that the MenuBar needs to be added to the frame as:
frame.setJMenuBar(menuBar);
instead of: frame.add(jMenuBar); along with: System.setProperty("apple.laf.useScreenMenuBar", "true"); in the main method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With