I know, there are lots of similar question around here with similar problems, but after reading tons of posts, I cannot simply solve this issue. Under Compiler > Resource Patterns, I've already put this string "*.fxml". Moreover, I've marked the resources folder as the Resources Root.
Here you can see my project structure:
This is my MainView.java class.
package dataParser.View;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class MainView extends Application {
private Stage primaryStage;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
this.primaryStage = primaryStage;
FXMLLoader loader = new FXMLLoader();
System.out.println(this.getClass().getResource("/MainView.fxml"));
loader.setLocation(getClass().getResource("/MainView.fxml"));
MainViewController mainViewController = new MainViewController();
mainViewController.setMainApp(this);
loader.setController(mainViewController);
Parent layout = loader.load();
Scene scene = new Scene(layout);
primaryStage.setScene(scene);
primaryStage.show();
}
Stage getPrimaryStage() {
return primaryStage;
}
}
Still, I'm just getting back a null resource. Any hints?
Thank you!
EDIT
This is the complete stack-trace. I've also noticed that I've issues linking all my resource files.
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:973)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:198)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2459)
at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2435)
at dataParser.View.MainView.start(MainView.java:29)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:919)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(PlatformImpl.java:449)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
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:175)
... 1 more