I'm developing an app for macOS. But when I try to add the JMenuBar
to the JFrame
instance it just adds the JFrame
window Instead of the macOS screen menu bar.
I've tried Following this Article and it didn't work :
It just overlapped the application title bar with the JMenuBar
.
I've read other articles online and still with no noticeable change.
JRE Info:
% javac --version
javac 17.0.4.1
JDK Info:
% java --version
java 17.0.4.1 2022-08-18 LTS
Java(TM) SE Runtime Environment (build 17.0.4.1+1-LTS-2)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.4.1+1-LTS-2, mixed mode, sharing)
I'm the author of the linked article (https://www.formdev.com/flatlaf/macos/). This definitely works.
Make sure that you invoke following in your main()
method before creating UI:
System.setProperty( "apple.laf.useScreenMenuBar", "true" );
Make sure to use JFrame.setJMenuBar(JMenuBar)
to add the menu bar to the frame.