CenterDevice NSMenuFX

NSMenuFX is a simple library allowing to access and modify the menu items that are generated by default for OS X applications

License

License

GroupId

GroupId

de.codecentric.centerdevice
ArtifactId

ArtifactId

centerdevice-nsmenufx
Last Version

Last Version

2.1.7
Release Date

Release Date

Type

Type

bundle
Description

Description

CenterDevice NSMenuFX
NSMenuFX is a simple library allowing to access and modify the menu items that are generated by default for OS X applications
Project URL

Project URL

https://github.com/codecentric/NSMenuFX
Project Organization

Project Organization

CenterDevice GmbH
Source Code Management

Source Code Management

https://github.com/codecentric/NSMenuFX

Download centerdevice-nsmenufx

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

NSMenuFX

Codacy Badge


NOTE

This repository is currently not receiving any updates.

More recent versions and new maven central coordinates can be found here: https://github.com/0x4a616e/NSMenuFX


A simple library to customize the OS X menu bar to give your JavaFX app a more native look and feel.

NSMenuFX helps you to

  • Customize the auto-generated application menu of your JavaFX app

Custom App Menu Screenshot

  • Create common OS X menus like the Window menu

Window Menu Screenshot

  • Quickly create an about menu

About Menu Screenshot

  • Automatically use the same menu bar for all stages

NSMenuFX is now completely written in JavaFX and does no longer use any further dependencies.

Maven

Add the following lines to the dependencies in your pom.xml

<dependency>
	<groupId>de.codecentric.centerdevice</groupId>
	<artifactId>centerdevice-nsmenufx</artifactId>
	<version>2.1.7</version>
</dependency>

Gradle

Add the following line to the dependencies in your build.gradle

compile "de.codecentric.centerdevice:centerdevice-nsmenufx:2.1.7"

Usage Examples

The following snippet shows a simple example on how to change a menu item in the application menu:

// Get the toolkit
MenuToolkit tk = MenuToolkit.toolkit();

// Create the default Application menu
Menu defaultApplicationMenu = tk.createDefaultApplicationMenu("test");

// Update the existing Application menu
tk.setApplicationMenu(defaultApplicationMenu);

// Since we now have a reference to the menu, we can rename items
defaultApplicationMenu.getItems().get(1).setText("Hide all the otters");

To set a global menu bar that is used for all stages:

// Create a new menu bar
MenuBar bar = new MenuBar();

// Add the default application menu
bar.getMenus().add(tk.createDefaultApplicationMenu("test"));

// Add some more Menus...

// Use the menu bar for all stages including new ones
tk.setGlobalMenuBar(bar);

To find more usage examples, have a look into the test classes.

Known issues

NSMenuFX no longer supports changing the title of the application menu at runtime. This has always been a bit "hacky" as it is not really supported by OS X. As a result, the new name was no longer bold faced when it was changed with previous versions of NSMenuFX.

To set the title of the application menu to the name of your application, you need to bundle the application and set CFBundleName in Info.plist.

de.codecentric.centerdevice

codecentric AG

Versions

Version
2.1.7
2.1.6
2.1.5
2.1.4
2.1.3
2.1.1
2.1.0
2.0.0
1.0.0