I have a project with such structure:
I trying to load sample.fxml from the Main class using this code:
Parent root = FXMLLoader.load(Main.class.getResource("../../submodule/src/java/sample.fxml"));
but it doesn't work. The sample.fxml file code is:
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<GridPane fx:controller="sample.Controller"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
</GridPane>
The problem is that FXML loader can't find this location. How to solve it?