I first time try to use JavaFx with Maven. By this topic: link IntelliJ can't recognize JavaFX 11 with OpenJDK 11, I configured project. But whatever I do I can't load fxml file, because "getClass().getResource(path)" return null.
I changed path, start it with '/' and without, changed packages, created packages, deleted packages, changed references in module-info, but this is not work.
struct: https://ibb.co/Hhwzk8b
module LogAggregator {
requires javafx.fxml;
requires javafx.controls;
opens fxml to javafx.fxml;
exports com.github.PavelKisliuk;
}
//----------------------------------------------------
public class Main extends Application {
public void start(Stage primaryStage) throws Exception {
String path = "fxml/Input.fxml";
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource(path));
Parent fxmlMainWindow = fxmlLoader.load();
//start-up window
//-----------------------------------------------
Scene s = new Scene(fxmlMainWindow);
primaryStage.setScene(s);
primaryStage.show();
}
public static void main(String... args) {
launch(args);
}
}
May be somebody know this problem and can help me. Without maven I don't have any problem's.
DECISION
Such path:
String path = "/fxml/Input.fxml";
Plus two string's to module-info:
opens com.github.PavelKisliuk.controller to javafx.fxml;
exports com.github.PavelKisliuk.controller to javafx.fxml;