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?
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?
Java applications look like traditional java applications even under OS X.
If you want a native look and feel, there are a few tweaks you have to do. This article series describes them.
http://www.oracle.com/technetwork/articles/javase/javatomac-140486.html http://www.oracle.com/technetwork/java/javatomac2-138389.html
This includes setting the Dock icon and text, and integrating with the Applications menu.
I believe that the OS X "wrap jar as an application" utility with XCode sets all these properties automatically.
By adding something like this into your code:
if (System.getProperty("os.name").contains("Mac")) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
}
if
check even necessary? Won't the property simply be ignored if you're not running on a mac? –
Coble 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.
Java applications look like traditional java applications even under OS X.
If you want a native look and feel, there are a few tweaks you have to do. This article series describes them.
http://www.oracle.com/technetwork/articles/javase/javatomac-140486.html http://www.oracle.com/technetwork/java/javatomac2-138389.html
This includes setting the Dock icon and text, and integrating with the Applications menu.
I believe that the OS X "wrap jar as an application" utility with XCode sets all these properties automatically.
© 2022 - 2024 — McMap. All rights reserved.