Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To place a Swing application’s menu in macOS’s screen-wide menu bar, set apple.laf.useScreenMenuBar to true before creating any Swing windows or components, then assign the menu normally with JFrame.setJMenuBar. The menu will appear beside the Apple menu when your application is active, instead of occupying the top of the window.

Quick fix

System.setProperty("apple.laf.useScreenMenuBar", "true");

// Later, after creating the menu:
frame.setJMenuBar(menuBar);

This is a macOS-specific system property consumed by the macOS/Aqua Swing implementation. It is not a method on JMenuBar and is not a portable Java SE setting. OpenJDK documentation and issue records associate the behavior with apple.laf.useScreenMenuBar=true and the Aqua look and feel (OpenJDK JDK-8188085).

Here, “system menu bar” means the menu bar fixed to the top of the display, containing the Apple menu and the active application’s name. It does not mean a Dock menu, menu-extra/status item, context menu, title-bar toolbar, or a menu bar moved to another edge of the screen. macOS displays application menus there while the application is active (Apple’s macOS guide).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Complete working example

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.UIManager;

public final class MacMenuExample {
    public static void main(String[] args) {
        if (System.getProperty("os.name", "").startsWith("Mac")) {
            // Set this before creating Swing UI objects.
            System.setProperty("apple.laf.useScreenMenuBar", "true");

            // Apple-specific compatibility property for the application name.
            System.setProperty(
                "com.apple.mrj.application.apple.menu.about.name",
                "My Application"
            );
        }

        EventQueue.invokeLater(() -> {
            try {
                UIManager.setLookAndFeel(
                    UIManager.getSystemLookAndFeelClassName()
                );
            } catch (Exception ex) {
                ex.printStackTrace();
            }

            JFrame frame = new JFrame("My Application");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JMenuBar menuBar = new JMenuBar();
            JMenu fileMenu = new JMenu("File");
            fileMenu.add(new JMenuItem("New"));
            fileMenu.add(new JMenuItem("Open"));
            fileMenu.addSeparator();
            fileMenu.add(new JMenuItem("Exit"));
            menuBar.add(fileMenu);

            // Use the standard Swing API; do not add the bar to the content pane.
            frame.setJMenuBar(menuBar);

            frame.setSize(640, 400);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        });
    }
}

On success, the File menu appears at the top of the macOS display and no longer consumes a strip inside the JFrame. Switching to another application changes the visible application menus.

#1 Best Overall
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Blush
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

Initialization order is essential

Set the property at application startup, before creating the first JFrame, creating or installing a JMenuBar, selecting the look and feel, or showing a window. Changing it after Swing has initialized is not a reliable way to relocate an existing menu. Restart after changing the setting.

You can test the setting without changing source code:

java -Dapple.laf.useScreenMenuBar=true -jar MyApplication.jar

The application-name property can also be supplied at launch:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Apple 2026 MacBook Air 13-inch Laptop with M5 chip: Built for AI, 13.6-inch Liquid Retina Display, 16GB Unified Memory, 512GB SSD, 12MP Center Stage Camera, Touch ID, Wi-Fi 7; Midnight
  • BUILT FOR COLLEGE. AND BEYOND — MacBook Air with the M5 chip packs blazing speed and powerful AI capabilities into an incredibly portable design. And with up to 18 hours of battery life,* this thin and light powerhouse is ready to take on almost any major, just about anywhere.
  • TEAR THROUGH TOUGH ASSIGNMENTS — With its faster CPU and unified memory, the M5 chip delivers even more performance and fluidity across apps, making multitasking and creative workflows smooth and responsive. A powerful Neural Engine and next-generation GPU with Neural Accelerators give you a powerful platform for AI.
  • MAKE QUICK WORK OF YOUR TO-DO LIST — Apple Intelligence helps you write, express yourself, and get things done effortlessly — whether it’s for school or everyday life. With groundbreaking privacy protections, it gives you peace of mind that no one else can access your data — not even Apple.*
  • UP TO 18 HOURS OF BATTERY LIFE — MacBook Air delivers incredible battery life with amazing performance, so you can power through a full day of classes without worrying about plugging in.
  • A BRILLIANT 13.6-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Air supports 1 billion colors, making photos and videos pop with rich contrast and sharp detail, and text appears supercrisp. So everything — from class presentations to movies to games — looks truly stunning.
java 
  -Dapple.laf.useScreenMenuBar=true 
  -Dcom.apple.mrj.application.apple.menu.about.name="My Application" 
  -jar MyApplication.jar

Older Apple and Oracle material uses com.apple.macos.useScreenMenuBar. Treat that as a historical name; lead with apple.laf.useScreenMenuBar for current macOS Swing implementations (Oracle’s historical Mac Java article; archived Apple documentation).

Choose the system look and feel

Calling UIManager.getSystemLookAndFeelClassName() before constructing components normally selects Aqua on macOS and gives the screen-menu integration the best chance of working. A custom look and feel may interfere with native menu rendering, keyboard accelerators, or platform conventions.

Do not import internal classes such as com.apple.laf.AquaLookAndFeel or com.apple.laf.AquaMenuBarUI. They are implementation details and may not be exported by modular JDKs; OpenJDK has documented module-access problems involving com.apple.laf (JDK-8166683). Use the public system-look-and-feel API instead.

Rank #3
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Indigo
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

Cross-platform startup

The property is intended for macOS. Guard it when the same application runs elsewhere:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
boolean macOS = System.getProperty("os.name", "")
        .toLowerCase()
        .contains("mac");

if (macOS) {
    System.setProperty("apple.laf.useScreenMenuBar", "true");
}

EventQueue.invokeLater(() -> {
    if (macOS) {
        try {
            UIManager.setLookAndFeel(
                UIManager.getSystemLookAndFeelClassName()
            );
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    createAndShowGui();
});

Windows and Linux should retain their normal in-window Swing menu unless you deliberately implement a platform-specific alternative.

Application name and the About menu

This Apple-specific compatibility property can influence the name shown in the macOS application menu and its About item:

Rank #4
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Citrus
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.
System.setProperty(
    "com.apple.mrj.application.apple.menu.about.name",
    "My Application"
);

It is not a portable Java API and its result can depend on the JDK, launch context, and packaging. It does not create a custom About dialog; add an action for that yourself if required. A bundled .app can provide a more native identity, Dock integration, and Info.plist metadata, but bundling is not required for the basic screen-menu property. Test both your intended JAR launch and packaged application.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The menu remains inside the window

  1. Move System.setProperty("apple.laf.useScreenMenuBar", "true") to the first lines of main.
  2. Restart the JVM.
  3. Confirm that the application is running on macOS with the target JDK.
  4. Try the JVM option -Dapple.laf.useScreenMenuBar=true.
  5. Use the system look and feel while diagnosing.

There is blank space where the menu used to be

Do not add the bar manually with add(menuBar, BorderLayout.NORTH). Remove that code and use only:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
frame.setJMenuBar(menuBar);

Then verify the property was set before UI creation. A custom look and feel or incomplete Aqua integration can also leave visual artifacts; test with the system look and feel first. Adjusting insets or adding a filler panel only hides the symptom.

Best Value
Sale
Apple 2026 MacBook Pro Laptop with Apple M5 Pro chip with 18-core CPU and 20-core GPU: Built for AI, 16.2-inch Liquid Retina XDR Display, 24GB Unified Memory, 1TB SSD, Wi-Fi 7; Space Black
  • FAST RUNS IN THE FAMILY — The 16-inch MacBook Pro with the M5 Pro or M5 Max chip brings next-generation speed and powerful on-device AI to personal, professional, and creative tasks. With all-day battery life, double the starting storage,* and a breathtaking Liquid Retina XDR display, it’s pro in every way.*
  • BUCKLE UP — Along with a next-generation CPU, faster unified memory, and up to 2x faster SSD storage,* M5 Pro and M5 Max feature a more powerful GPU with a Neural Accelerator built into each core, delivering faster AI performance and on-device training capabilities. So you can blaze through demanding workloads at mind-bending speeds.
  • BUILT FOR AI — Apple silicon, and every major component that powers it, is designed to run demanding on-device AI workloads like LLM inference and training. And Apple Intelligence helps you write, express yourself, and get things done effortlessly with groundbreaking privacy protections at every step.*
  • ALL-DAY BATTERY LIFE — MacBook Pro delivers the same exceptional performance whether it’s running on battery or plugged in.*
  • MACOS RUNS APPS FAST — All your go-to apps run lightning fast in macOS, including built-in apps like FaceTime and Messages. Plus, built-in virus protection and free software updates help keep your Mac running smoothly and securely.

Command-key accelerators fail

Define shortcuts with the platform menu modifier rather than hard-coding Control:

menuItem.setAccelerator(KeyStroke.getKeyStroke(
    KeyEvent.VK_O,
    Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
));

Test Command-key actions, nested menus, focus changes, and switching between windows. The modifier is normally Command on macOS.

Multiple windows show unexpected menus

Each JFrame can have its own menu bar. The active window/application context determines what macOS presents, so decide whether menus are shared or window-specific and test window switching. A default menu can be useful when no frame is active, but it adds different behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When to use Desktop.setDefaultMenuBar

Desktop.setDefaultMenuBar is an advanced option for keeping a menu available when no frame is active. OpenJDK’s macOS implementation relates it to screen-menu operation when the property is enabled and Aqua is active (OpenJDK macOS source). It should not replace frame.setJMenuBar(menuBar) for an ordinary single-window application. OpenJDK has recorded accelerator problems with the default-menu approach that did not occur when the same menu was assigned to a frame (JDK-8333589). Use it only when the no-window state is a real requirement and test shortcuts on every target JDK.

Compatibility notes and verification checklist

apple.laf.useScreenMenuBar is macOS-specific implementation behavior, not a guaranteed portable Java SE contract. Exact behavior may vary across JDK versions and alternative runtimes. The public JMenuBar API remains the correct way to construct and assign the menu; macOS integration supplies the screen-wide presentation.

  • Run on macOS with the JDK you ship.
  • Set the property before any Swing UI initialization.
  • Use setJMenuBar, not a manual content-pane add.
  • Test with the system/Aqua look and feel.
  • Verify the menu appears at the top of the display and disappears from the frame.
  • Test Command-key accelerators and nested menu items.
  • Test focus changes, multiple windows, and application switching.
  • Test the actual JAR or bundled .app launch format.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.