Reputation: 39
I'm pretty new to Maven and JavaFX so I'm assuming there's an easy answer, but I haven't been able to find it.
I want to create a GUI for my project, which I have as a maven project in IntelliJ. I was able to get a GUI to function as intended by adding javafx-fxml
and javafx-controls
. When wanting to try SceneBuilder I realized that the .fxml file was nowhere to be found.
Some sources say to look in the resources folder but that appears to be empty. Another says there is a second src folder(?) but if that's the case I can't find it.
Upvotes: 0
Views: 1315
Reputation: 4054
Assume your package name is com.example
Then your Application code is here <project root>\src\main\java\com\example\App.java
Place your FXML here <project root>\src\main\resources\com\example\App.fxml
Load your FXML using Java code
Parent root = FXMLLoader.load(getClass().getResource("App.fxml"));
Scene scene = new Scene(root);
App.java
as well as App.fxml
are in the same package, therefore getClass().getResource("App.fxml")
works fine
Upvotes: 2