Code Monkey home page Code Monkey logo

nsmenufx's Introduction

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.

nsmenufx's People

Contributors

0x4a616e avatar airsquared avatar codacy-badger avatar codingfabian avatar jkaving avatar mipastgt avatar msgilligan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nsmenufx's Issues

[Request] Help menu localisation

I have noticed that menus called "Help" (example code) will have a search panel (like native OSX applications, localized with the system's language setting) as first menu item automatically.

When I rename the menu "Help" to a localized variant (like German: "Hilfe") the search panel will be not added.

A function in de.codecentric.centerdevice.MenuToolkit to create a help menu with a custom name or a function to create the search panel menu item would be nice.

Checkmark icon for frontmost window

The Windows menu lists displayed windows and allows bringing a window to the front by selecting it. (Cool!)

However, it should place a checkmark in front of the name of the currently selected window.

Create CHANGELOG or release notes

It would be nice to have a CHANGELOG or release notes showing each release and major changes made in that release. For example: bitcoinj-addons CHANGELOG

(If you're OK with the above example format, I can make a pull request -- are you open to using AsciiDoctor markdown for the CHANGELOG and/or README? I prefer it for all documentation, but am happy to use standard Github markdown if you prefer)

[QUESTION] pure-javafx solution

I am really new to git and github so I might be asking at the wrong place. Sorry if that is actually happening.
I just wanted to ask why the pure-javafx branch is 4 commits behind the master? Do you just use it as an alternative solution to the swt based library?

Cheers,
Sven

Create NSMenuFX 3.0 for JDK 11+

Given the rapid improvements in OpenJDK and OpenJFX, the availability of bundled runtimes via jlink and jpackage, the difficulty of supporting the changes in configuration that occurred between JDK 8 and JDK 11, I propose that we create version 3.0 of NSMenuFX that requires JDK 11 at a minimum.

Among other things, this would enable us to include a module-info.jar file and not worry about backward compatibility with JDKs prior to Java 11.

People that need earlier JDKs could use the 2.1.x versions.

child window cancel close of main window

I have an application that I moved from Windows to Mac. It creates child windows from the parent window. A child window can cancel the close of the application. However, the sequence of events is causing a problem. When I execute Command Q, the main windows closes first. I can still cancel the close of the child window but the main window is gone. Is there an option that I'm missing that causes the child windows to try to close first? I've attached a modified form of StandardMacApp that shows what I want to do. Thanks.
StandardMacApp.java.zip

Provide a Maven release with localization

Thanks for sharing the menu adapter - a great help for my ScalaFXML applications.

Could you provide a new Maven release which includes the latest localization feature? Currently I am using a GIT clone of the project and create a private build to take advantage of the German localization.

Thanks and regards,
Peter

Java 9 Issue

Alright, so I love your library, and I am using for a senior project. However, upong upgrading my project to 1.9 (to get access to the Desktop class), I now receive this error:

WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by de.codecentric.centerdevice.util.ReflectionUtils (file:/Users/diegobatista/Git%20Repositories/SURPG/Java%20Libraries/NSMenuFX.jar) to field com.sun.javafx.tk.quantum.GlassSystemMenu.glassSystemMenuBar WARNING: Please consider reporting this to the maintainers of de.codecentric.centerdevice.util.ReflectionUtils WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release Exception in thread "JavaFX Application Thread" java.lang.NoSuchMethodError: com.sun.javafx.stage.StageHelper.getStages()Ljavafx/collections/ObservableList;

I don't know if this has to do with the change of JavaFX with Java 9, but this didn't happen before. Please help! Thanks.

MenuToolkit returns null under MacOSX

I am developing under Mac, when I create a simple demo javafx application, it's ok.

when I put same logic code into another javafx application, I failed with exception below:

2020-11-21 10:04:11,463 INFO  [main] c.k.keebox.KeeboxFXApplication$ - Starting KeeboxFXApplication. using Java 15 on fq16.lan with PID 18369 (/Users/fq/workspace.keevol/KeeboxNative/target/classes started by fq in /Users/fq/workspace.keevol/KeeboxNative)
2020-11-21 10:04:11,465 INFO  [main] c.k.keebox.KeeboxFXApplication$ - No active profile set, falling back to default profiles: default
2020-11-21 10:04:12,435 INFO  [main] c.k.keebox.KeeboxFXApplication$ - Started KeeboxFXApplication. in 1.309 seconds (JVM running for 3.933)
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
	at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.NullPointerException: Cannot invoke "de.codecentric.centerdevice.MenuToolkit.createDefaultApplicationMenu(String, javafx.stage.Stage)" because "tk" is null
	at com.keevol.keebox.KeeboxFXApplication.start(KeeboxFXApplication.scala:112)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)

the code part is:

    val scene = new Scene(layout)
    scene.getStylesheets.add(getClass.getResource("/css/style.css").toExternalForm)
    stage.setScene(scene)

    val tk = MenuToolkit.toolkit(Locale.getDefault). 
    tk.setApplicationMenu(tk.createDefaultApplicationMenu("KEEBOX", stage)). // <<<<<<--here

    stage.setTitle("KEEBOX")
    stage.getIcons.add(Images.LOGO)
    stage.show()

I debug into the code , found isSupported() returns false and then everything return null.

But it doesn't make sense, and I don't know why. The only difference between these two application is in the latter, I run springboot first and launch javafx second, But I don't think that's culprit for isSupported return false.

any hint?

Use Swing instead of SWT

This is somewhere in-between a question and a feature request. A little of both I guess.

Why use SWT instead of Swing? Since Swing is bundled with the JRE, couldn't Swing be used to build the Mac OS menus in the same way you are doing with SWT. Then there would be no external dependencies -- especially natively compiled ones.

Nullpointer when set/get Menu from Adapter

Hi,
when you initialize your UI (and the Menu) before stage.show() call you get following exception:

Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157)
at com.sun.javafx.application.LauncherImpl$$Lambda$1/668386784.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at de.codecentric.centerdevice.platform.osx.NSMenuBarAdapter.clear(NSMenuBarAdapter.java:158)
at de.codecentric.centerdevice.platform.osx.NSMenuBarAdapter.setMenuBar(NSMenuBarAdapter.java:35)
at de.saxsys.pitfalls.osxmenu.SampleMenuBar.start(SampleMenuBar.java:55)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/1325180719.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/947728675.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$49/1778216420.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1297161816.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

NSMenuFX always crash in mac os sierra 10.12.4

Hi, I have integrate your NSMenuFX into my javafx application. But, it will always lead my mac os crash, when it crash, I couldn't use my keyboard, mouse and control panel, so I can not get the error log.
But, some days ago, I use the method menuBar.setUseSystemMenuBar(true); this method will lead my os crashing.
So, Sir, I find that you use the same method in class MenuBarUtils, line 20.
I think it may be the bug of the mac os sierra or the jdk.

My jdk : 1.8.0_131
My os : mac os sierra 10.12.4
My IDE: Intellij IDEA 2017.1

Remove dependency on 'javafx.web' module.

On JavaFX 11, I found I had to add a dependency on javafx.web even though I'm not actually using the default "About" stage (window)

I think I can work around this by calling createDefaultApplicationMenu with a preexisting Stage, but for a modular JDK, it would be nice if the menu library didn't have a dependency on javafx.web at all.

IllegalAccessError on OpenJFX 11

glavo@glavo:~/IdeaProjects/ClassViewer/build/libs$ java --module-path $OPENJFX11_SDK --add-modules javafx.controls -jar ClassViewer-4.0-release.jar 
Exception in Application start method
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalAccessError: class de.codecentric.centerdevice.glass.AdapterContext (in unnamed module @0x125f5c1) cannot access class com.sun.javafx.tk.Toolkit (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.tk to unnamed module @0x125f5c1
	at de.codecentric.centerdevice.glass.AdapterContext.createContext(AdapterContext.java:34)
	at de.codecentric.centerdevice.glass.AdapterContext.getContext(AdapterContext.java:19)
	at de.codecentric.centerdevice.MenuToolkit.toolkit(MenuToolkit.java:57)
	at de.codecentric.centerdevice.MenuToolkit.toolkit(MenuToolkit.java:53)
	at de.codecentric.centerdevice.MenuToolkit.toolkit(MenuToolkit.java:49)
	at org.glavo.viewer.gui.Viewer.start(Viewer.java:18)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
	at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
	... 1 more
Exception running application org.glavo.viewer.gui.Viewer

Global menubar reset on any window change

The code in StageUtils.updateStages() currently has the effect that a global menubar will be reset on all stages on any window change.
The call to setAll(newStages) here will trigger stage listeners even if there has been only changes no non-stage windows and no changes to any stage:

private static void updateStages() {
	List<Stage> newStages = new LinkedList<>();
	for (Window w : windows) {
		if (w instanceof Stage) {
			newStages.add((Stage)w);
		}
	}
	stages.setAll(newStages);		
}

If a global menu bar has been set this will trigger this code in MenuBarSyncListener.

stageChanges.getAddedSubList().forEach(stage -> MenuBarUtils.setMenuBar(stage, MENU_BAR));

If popup windows are used when hovering over elements in a scene the effect will be that the system menubar on MacOS flickers when popup windows are shown or hidden.

Any way to change the icon that displays in "About"?

Hi,

I noticed that NSMenuFX always loads a generic icon from the system. Will it ever be possible to change this?

Also, will the copyright text ever be customizable?
These would both be nice things to see.

Thanks.

Unable to cancel application closing using Cmd+q

I've created a demo program to highlight this issue, which can be found here:
https://github.com/liamsharp/NSMenuFX-quit-issue

The demo program just throws up a pop up allowing you to cancel a setOnCloseRequest by consuming the WindowEvent if the user clicks Cancel.

Using version 2.1.0 when I hit Cmd+q and get the pop up and choose cancel the application stays open as expected. If I rev to 2.1.1 or later in the pom.xml and do the same, the application exits, which it shouldn't.

I think this was introduced here:
e31ac5a

Please do let me know if you need anymore info!

Issue while using SHORTCUT in the main applicaton menu

Hallo Team ,

There is an issue when I use the shortcut with any menuitem present in the app menu, it never shows the command key. But if use the same in anyother menu which I have created it shows proper command key, Also the shift command doesnt work with any of the menuitems.

Example :

Appmenu (Menu with APP NAME) -> menuitem1 with keycombination SHORTCUT+B (which should display as command key and B, only displays B). If use META_DOWN instead of SHORTCUT it shows the command key.
Viewmenu -> menuitem1 with keycombination SHORTCUT+C (Shows proper command key and C)

I'm using the below method and passing the key combination as String as shown above.
item.setAccelerator(KeyCombination.keyCombination("SHORTCUT+B"));

NPE Input stream must not be null on MacOS Big Sur beta

We have customers trying out our application in MacOS Big Sur and they are experiencing the following crash in our application:

15:25:12,623 [JavaFX Application Thread] (CrashHandler.java:129) FATAL - Thread: Thread[JavaFX Application Thread,5,main]
java.lang.NullPointerException: Input stream must not be null
	at javafx.scene.image.Image.validateInputStream(Image.java:1117) ~[javafx-graphics-12.0.14-sf13-mac.jar:?]
	at javafx.scene.image.Image.<init>(Image.java:701) ~[javafx-graphics-12.0.14-sf13-mac.jar:?]
	at de.codecentric.centerdevice.MenuToolkit.createDefaultAboutStage(MenuToolkit.java:85) ~[centerdevice-nsmenufx-2.1.6.jar:?]
	at de.codecentric.centerdevice.MenuToolkit.createDefaultApplicationMenu(MenuToolkit.java:66) ~[centerdevice-nsmenufx-2.1.6.jar:?]

The crash is due to the call to IcnsParser.getIconStream() returning null. It's looking for a "ic08" icon type which now no longer exists in /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericApplication.icns.

Comparing this with the equivalent file in Catalina, I can see that Catalina's version has 10 icons compared to Big Sur which has only 4 in the icon set.

Are there any plans to test this with the current MacOS Big Sur beta?

Thanks

NPE when new stage calls show()

I'm getting the following stack trace when a new stage calls show():

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
	at de.codecentric.centerdevice.util.MenuBarUtils.setMenuBar(MenuBarUtils.java:29)
	at de.codecentric.centerdevice.listener.MenuBarSyncListener.lambda$onChanged$0(MenuBarSyncListener.java:37)
	at java.lang.Iterable.forEach(Iterable.java:75)
	at de.codecentric.centerdevice.listener.MenuBarSyncListener.onChanged(MenuBarSyncListener.java:37)
	at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
	at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
	at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
	at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
	at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
	at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
	at javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:155)
	at java.util.AbstractList.add(AbstractList.java:108)
	at javafx.stage.Stage.impl_visibleChanging(Stage.java:1164)
	at javafx.stage.Window$9.invalidated(Window.java:824)
	at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:109)
	at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:144)
	at javafx.stage.Window.setShowing(Window.java:922)
	at javafx.stage.Window.show(Window.java:937)
	at javafx.stage.Stage.show(Stage.java:259)
	at com.datastax.support.GraphicalClient.displayTicket(GraphicalClient.java:667)
	at com.datastax.support.GraphicalClient.displayTicket(GraphicalClient.java:635)
	at com.datastax.support.GraphicalClient.lambda$openMyTickets$16(GraphicalClient.java:630)
	at java.util.ArrayList.forEach(ArrayList.java:1249)
	at com.datastax.support.GraphicalClient.openMyTickets(GraphicalClient.java:630)
	at com.datastax.support.GraphicalClient.start(GraphicalClient.java:465)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
	at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
	

I'm using JDK 1.8.0_121 on MacOS (latest)

I'm running the program from the IDE (Idea), same behavior if I build a native package.

The window menu never showed up, so I commented it out to see if the NPE still occurs, and it does. The about menu item does work properly.

Am I doing something wrong?

The following method is called from Start():

 private void setMacMenuBar() {
        final String os = System.getProperty("os.name");
        if (os != null && os.startsWith("Mac")) {
            MenuToolkit tk = MenuToolkit.toolkit();
            Menu defaultApplicationMenu = tk.createDefaultApplicationMenu("Zendesk Downloader Tool");
            tk.setApplicationMenu(defaultApplicationMenu);
            MenuBar bar = new MenuBar();
//            Menu windowMenu = new Menu("Window");
//            windowMenu.getItems().addAll(tk.createMinimizeMenuItem(), tk.createZoomMenuItem(), tk.createCycleWindowsItem(),
//                    new SeparatorMenuItem(), tk.createBringAllToFrontItem());
            bar.getMenus().addAll(defaultApplicationMenu);
//            bar.getMenus().addAll(defaultApplicationMenu, windowMenu);

         tk.setGlobalMenuBar(bar);
  }

Global Menu Bar not visible during all stages

Hi All,

I have found a problem that's a show stopper for using this library in a project I'm developing.

I have a complex program that opens multiple stages, and for some windows/stages the global menu bar just doesn't show up. If a dialog box is opened, the global menu bar is visible while that box has focus. The menu bar shows up during the initial stage as well, which is a login window that calls Stage().showAndWait();

I have stripped down to a simple demonstration program and am attaching to this report. It's a gradle Idea project that uses gradle wraper.

Thanks,

Michael
demonstration.zip

de.codecentric.centerdevice.dialogs.about.AboutController not found

I am using NSMenuFX 2.1.4 in an OSGi (Felix 5.4.0) application with JDK 1.8.0_76-ea on an iMac running macOS Sierra 10.12.3. Other relevant software involved: NetBeans 8.2, Maven 3.3.3.

After a call tomenu = menuToolkit.createDefaultApplicationMenu("ABC"); I get the following stack dump:

javafx.fxml.LoadException: 
/about.fxml:7

	at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
	at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:103)
	at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:922)
	at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
	at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
	at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
	at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
	at de.codecentric.centerdevice.dialogs.about.AboutStageBuilder.prepareStage(AboutStageBuilder.java:44)
	at de.codecentric.centerdevice.dialogs.about.AboutStageBuilder.build(AboutStageBuilder.java:35)
	at de.codecentric.centerdevice.MenuToolkit.createDefaultAboutStage(MenuToolkit.java:90)
	at de.codecentric.centerdevice.MenuToolkit.createDefaultApplicationMenu(MenuToolkit.java:66)

        ...

Caused by: java.lang.ClassNotFoundException: de.codecentric.centerdevice.dialogs.about.AboutController
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:920)
	... 23 more

The bundle is loaded and active:

g! lb
START LEVEL 1
   ID|State      |Level|Name
   ...
   12|Active     |    1|CenterDevice NSMenuFX (2.1.4)|2.1.4
   ...

trouble integrating bundle

I've added a reference to your maven bundle from my OSGi project but I'm getting this error when I run it. Are there other dependencies that I'm missing? The error only shows up when I try to instantiate a menu bar adapter.

org.osgi.framework.BundleException: Unresolved constraint in bundle org.daisy.pipeline.gui [77]: >Unable to resolve 77.0: missing requirement [77.0] osgi.wiring.package;
(osgi.wiring.package=de.codecentric.centerdevice.platform.osx)

LabelMaker.getResourceName() returns wrong file name.

In the class LabelMaker.java the method getResourceName() return wrong name.
You should use locale.toLanguageTag() or concat at least 2 strings manually _, e.g. menu_labels_fr_FR.properties.
For example, in Canada and in France using French, but different dialects.

Java 9 compatibility issues

Hello there :)

I know that it will take some time till Java 9 is coming out but they already announced that they want to modulize the JRE. That means that they can tweak which packages will be available to use (in a way that osgi is already doing it with the 'Export-Packages' property). That would sadly mean that your solution (using the sun classes) would not run and throw a SecurityException because you are trying to access classes that can't be accessed from the outside of personal package names.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.