0

I converted my "normal" Javafx project into a maven project to generate a modular image. Now I get this error pressing a menu button to load a fxml file. Despite the error, the fxml is still loaded.

@FXML
private AnchorPane content = new AnchorPane();
@FXML
private Menu diagramOptions;
@FXML
void openSimpleMode(ActionEvent event) throws InvalidFileFormatException, IOException {
    diagramOptions.setVisible(true);
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/SimpleMode.fxml"));
    Node simpleModePane = null;
    try {
        simpleModePane = loader.load();
    } catch (Exception e) {
        System.out.println("error in loading pane");
    }
    content.getChildren().clear();
    content.getChildren().add(simpleModePane);
    simplecontroller = loader.getController();
    if (simplecontroller != null) {
        simplecontroller.initData(ldfParser, methods, this);
    } else {
        System.out.println("null Pointer exception");
    }
     System.out.println("error after this");
}

if I delete diagramOptions.setVisible(true); the error did not appear

full stacktrace:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot invoke "javafx.scene.control.MenuButton.getScene()" because the return value of "javafx.scene.control.skin.MenuButtonSkinBase.getSkinnable()" is null
    at javafx.controls/javafx.scene.control.skin.MenuButtonSkinBase.lambda$new$7(MenuButtonSkinBase.java:188)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    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.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:832)

Before converting it into maven everything works fine

Slaw
  • 25,955
  • 5
  • 33
  • 58
Der Altmann
  • 127
  • 6
  • 2
    Hmm. The stack trace does not show any of your code, only JavaFX code. Can you provide a [mre]? – Slaw Jan 12 '21 at 09:02

1 Answers1

1

the problem was a bug in javafx. I switched to version 15 and everything is working fine

Der Altmann
  • 127
  • 6