Salut tout le monde, ce code est issu d'un cours Java, les chemins pour les fichiers FXML sont correctes, mais je reçois toujours cette erreur.
Erreur :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 import java.io.IOException; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class MainClass extends Application { private Stage stagePrincipal; private BorderPane conteneurPrincipal; @Override public void start(Stage primaryStage) { stagePrincipal = primaryStage; stagePrincipal.setTitle("Application de gestion de personnes"); initialisationConteneurPrincipal(); initialisationContenu(); } private void initialisationConteneurPrincipal() { FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainClass.class.getResource("person/Two.fxml")); try { conteneurPrincipal = (BorderPane) loader.load(); Scene scene = new Scene(conteneurPrincipal); stagePrincipal.setScene(scene); stagePrincipal.show(); } catch (IOException e) { e.printStackTrace(); } } private void initialisationContenu() { FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainClass.class.getResource("person/One.fxml")); try { AnchorPane conteneurPersonne = (AnchorPane) loader.load(); conteneurPrincipal.setCenter(conteneurPersonne); } catch (IOException e) { e.printStackTrace(); } } public static void main(String[] args) { launch(args); } }
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 Exception in Application start method java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051) Caused by: java.lang.RuntimeException: Exception in Application start method at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.IllegalStateException: Location is not set. at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2459) at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2435) at person.MainClass.initialisationConteneurPrincipal(MainClass.java:102) at person.MainClass.start(MainClass.java:91) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174) ... 1 more Exception running application person.MainClass