Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
288 views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...