I have a JavaFX project with Gradle built tool. What is the right way to construct the src/main/resources folder so that I could easily access the *.fxml and *.css by simple line of code:
Parent root = FXMLLoader.load(getClass().getResource("xxx.fxml"));
I'm using the Gradle plugin and build.gradle file for JavaFX in this tutorial, It has a simple project tree like this:
.
├── src.main
| ├── java
| | ├── org.openjfx
| | | ├── MainApp.java
| | └── └── FXMLController.java
| ├── resources
| | ├── org.openjfx
| | | ├── scene.fxml
└── └── └── └── styles.css
In this way, the MainApp.java can load scene.fxml using getResource("scene.fxml").
However, if the java and the resources directory structures doesn't match, suppose my project tree like this so that I could separate the fxml file and css file:
.
├── src.main
| ├── java
| | ├── org.openjfx
| | | ├── anotherPackage
| | | | ├── MainApp.java
| | └── └── FXMLController.java
| ├── resources
| | ├── org.openjfx
| | | ├── layouts
| | | | ├── scene.fxml
| | | ├── styles
└── └── └── └── └──styles.css
Now the MainApp.java have to load scene.fxml with getResource("../layouts/scene.fxml")
I am new to Gradle and JavaFX, and I want to know what is the right way to manage the resources including fxml, CSS, as well as pictures, etc.
ps. Sorry if I'm not asking the question correctly.