I was trying to use NSMenuFX
from https://github.com/codecentric/NSMenuFX to make a JavaFX app use the MacOS System MenuBar, and it didn't work because of this method returning always false
.
Toolkit.getToolkit().getSystemMenu().isSupported()
The method is from the package : com.sun.javafx.tk.Toolkit
.
Going deeper in the code I've found that Toolkit.getToolkit().getSystemMenu().isSupported()
calls a method from com.sun.glass.ui.Application
that returns always false too.
protected boolean _supportsSystemMenu() {
return false;
}
public final boolean supportsSystemMenu() {
checkEventThread();
return this._supportsSystemMenu();
}
Is there something wrong about this code, and how can i get JavaFX app using the System menubar.
NB :Used JDK is 8u121 on OSX 10.12.3.
Edit 1 : As suggested in comments, here is some code.
import javafx.scene.control.MenuBar;
public class MyappMenuBar extends MenuBar {
// member variables -------------------------------------------------------------------------
private final MyappPane mmyappPane;
public MyappPane getMyappPane() {return mMyappPane;}
private final MyappHelpMenu mHelpMenu;
public MyappHelpMenu getHelpMenu() {return mHelpMenu;}
// constructors -----------------------------------------------------------------------------
public myappMenuBar(MyappPane pMyappPane) {
mMyappPane = pMyappPane;
setUseSystemMenuBar(true);
mHelpMenu = new MyappHelpMenu(pMyappPane);
getMenus().add(mHelpMenu);
}
}