Issue with getResource() in JavaFX - FXML file not found

27 Views Asked by At

I'm having issue with gerResource().

public class MainApp extends Application {
...
    public void initRootLayout() {
        try {
            // load `rootLayout.fxml`
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(MainApp.class.getResource("/proj/addapp/RootLayout.fxml"));
            rootLayout = loader.load();
            Scene scene = new Scene(rootLayout);
            primaryStage.setScene(scene);
            primaryStage.show();

            // ...
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
...

I have RootLayout.fxml file in proj.addapp package along with MainApp, but it seems fxml can't be found. I've been looking for awhile but wasn't able to find the answer.

I've tried different pathway and rebuild the project.

0

There are 0 best solutions below