I\'m using IntelliJ IDEA 13.1.5, I used to work with Eclipse. I\'m working on JavaFX application, I try to load FXML file within my MainApp class using getClass().getResourc
first, you need to set src and resource folders for IntelliJ.
see the icon near the java(blue) and resources(yellow 4 lines) folder.
right-click on java folder and select sources root
and right-click on java folder and select resource root
after that create the same package in the java folder and resource folder.
for example: packages -> org.example
├─ src
├─ main
├─ java
| └─ com
| └─ example
| └─ A.class
|
└─ resources
└─ com
└─ example
└─ fxml
└─ AFXML.fxml
in A.class you can use this.
Java
FXMLLoader loader = new FXMLLoader(getClass().getResource("fxml/AFXML.fxml"));
Parent root = loader.load();
Kotlin
val loader = FXMLLoader(javaClass.getResource("fxml/AFXML.fxml"))
val root = loader.load()
or
val loader = FXMLLoader(A::class.java.getResource("fxml/AFXML.fxml"))
val root = loader.load()