JavaFX:IllegalStateException:必须提供位置

问题描述 投票:0回答:1

我正在尝试为我的应用加载FXML,就像在另一个项目中所做的那样。差异:不起作用。我收到“ IllegalStateException:必须提供位置”

我试图将文件移动到其他位置,但这也不起作用。我用调试器检查了URL(tmp)。它指向正确的文件。

    URL tmp = getClass().getClassLoader().getResource("FXMLDocument.fxml");
    FXMLLoader baseLoader = new FXMLLoader(tmp);
    Parent root = baseLoader.load();
    Scene scene = new Scene(root);        
    stage.setScene(scene);
    stage.show();
java javafx illegalstateexception fxmlloader
1个回答
-1
投票

请替换:

URL tmp = getClass().getClassLoader().getResource("FXMLDocument.fxml");

to

URL tmp = getClass().getResource("FXMLDocument.fxml");
© www.soinside.com 2019 - 2024. All rights reserved.