Zizouz212
Zizouz212

Reputation: 4998

Edit the application menu on OS X

When you set a JMenu in Swing on OSX, with the title of "Menu", Apple already transforms the menu so it can perform "help" operations?

Menubar Help

The search bar is automatically added at the top, despite having not manually added such thing. In this context, I can add menus to this "pre-made" menu.

However, how would I do that for the App menu?

App Menu

Here's an example of what I would like to do:

Safari Menu

You can see items such as "Safari Extensions...". I need to add my own menu's there, so that my end audience will be able to configure things such as settings.

Is there a way to add JMenuItems to the default application menu in Swing? I'm looking to add extra menu's.

Upvotes: 2

Views: 612

Answers (1)

martinez314
martinez314

Reputation: 12332

Usually what you find in the app menu are settings-related menu options. You can add a Preferences menu, but that's all -- no further customization beyond that. To do that you add a PreferencesHandler:

myApp.setPreferencesHandler(new PreferencesHandler() {
    public void handlePreferences(PreferencesEvent paramPreferencesEvent) {
        // do something
    }
});

A Mac user will look there for your app's Preferences. I'd suggest putting everything settings-related in there.

There isn't really much documentation out there for this anymore, but this tutorial seems to still have a lot of information: http://moomoohk.github.io/snippets/java_osx.html

Upvotes: 1

Related Questions