I'm trying to load a CSS stylesheet with the following code in my controller's initialize method:
public class Controller implements Initializable {
#FXML BorderPane rootPane;
#FXML TextField txtTest;
#FXML Button btnSayHey;
#FXML Button btnLookMa;
#Override
public void initialize(URL arg0, ResourceBundle arg1) {
String styleFile = "res/striped-progress.css";
URL url = getClass().getResource(styleFile);
rootPane.getStylesheets().add(url.toString());
}
}
however upon launching the app, there's a javafx.fxml.LoadException being thrown and looking at the stacktrace, I can see that
rootPane.getStylesheets().add(url.toString());
is causing a NullPointerException. My start method is as follows:
#Override
public void start(Stage primaryStage) throws Exception {
String sceneFile = "scripts/DEV/PLAYGROUND/STYLES/res/MainView.fxml";
Parent root = null;
URL url = null;
try
{
url = new File(sceneFile).toURI().toURL();
root = FXMLLoader.load( url );
System.out.println( " fxmlResource = " + sceneFile );
}
catch ( Exception ex )
{
System.out.println( "Exception on FXMLLoader.load()" );
System.out.println( " * url: " + url );
System.out.println( " * " + ex );
System.out.println( " ----------------------------------------\n" );
throw ex;
}
BorderPane page = (BorderPane) root;
Scene scene = new Scene(page);
primaryStage.setScene(scene);
primaryStage.setTitle("SampleCSS App - v1.0");
primaryStage.show();
}
And console stacktrace is here:
Exception on FXMLLoader.load()
* url: file:/C:/rangedb/workspaces/UKRangeDBdemo/app_RVSW/scripts/DEV/PLAYGROUND/STYLES/res/MainView.fxml
* javafx.fxml.LoadException:
/C:/rangedb/workspaces/UKRangeDBdemo/app_RVSW/scripts/DEV/PLAYGROUND/STYLES/res/MainView.fxml
----------------------------------------
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:363)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:303)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157)
at com.sun.javafx.application.LauncherImpl$$Lambda$49/1545327692.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
/C:/rangedb/workspaces/UKRangeDBdemo/app_RVSW/scripts/DEV/PLAYGROUND/STYLES/res/MainView.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2595)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2573)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2435)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3208)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3169)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3142)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3118)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3098)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3091)
at DEV.PLAYGROUND.STYLES.ExternalStylesSample.start(ExternalStylesSample.java:79)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
at com.sun.javafx.application.LauncherImpl$$Lambda$52/897256917.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/661672156.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1517660793.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/128893786.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$38/1349277854.run(Unknown Source)
... 1 more
Caused by: java.lang.NullPointerException
at DEV.PLAYGROUND.STYLES.Controller.initialize(Controller.java:49)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2542)
... 22 more
Exception running application DEV.PLAYGROUND.STYLES.ExternalStylesSample
You'll notice that simply commenting out/deleting the line
rootPane.getStylesheets().add(url.toString()); in initialize() will cause all the errors to go away, but this will not load the CSS stylesheet.
Update:
Adding package structure under James_D's advice :
(I've managed to fix my own problem thanks to James_D's comments. So here goes... )
The NullPointerException was being caused by me not initialising the BorderPane object in my MainView.fxml file. After setting the fx:id of the BorderPane in the fxml file as rootPane (note: this name was set to rootPane because in my Controller, I have a #FXML injected field:
#FXML Parent rootPane;
after making this change, almost all errors were gone. Except the following runtime warning:
com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged
INFO: Could not find stylesheet: file:/C:/rangedb/workspaces/UKRangeDBdemo/app_RVSW/res/striped-progress.css
Albeit the CSS was being applied to my controls during runtime. Turns out one can load the stylesheet in a 'privileged' manner by simply using toExternalForm() on the URL object that was being returned by:
getClass().getResource("res/striped-progress.css")
In other words, I changed the above line of code to:
rootPane.getStylesheets().add(getClass().getResource("res/striped-progress.css").toExternalForm());
toExternalForm() returns a String representation of the URL object but I'm not sure why not using it causes a warning and using it doesn't. Either way, it works.
Related
So my application runs and functions normally when I run it through intellij, but when I export the application it wont even launch. This is the Stack Trace I get.
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at application.UIController.start(UIController.java:42)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Exception running application application.UIController
Process finished with exit code 1
This is the code that it is complaining about.
public void start(Stage stage) {
screen = stage;
try {
FXMLLoader loader = new FXMLLoader(UIController.class.getResource("/fxml/LoginFXML.fxml"));
Parent root = loader.load();
loginController = loader.getController();
Scene scene = new Scene(root, 340, 487);
scene.getStylesheets().add(getClass().getResource("/css/application.css").toExternalForm());
screen.setScene(scene);
screen.show();
screen.setResizable(false);
screen.setTitle("Room Booking System");
if (launched.equals(false)) {
launched = true;
Database_Control launchdb = new Database_Control();
launchdb.launch();
}
Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
screen.setX((screenBounds.getWidth() - screen.getWidth()) / 2);
screen.setY((screenBounds.getHeight() - screen.getHeight()) / 2);
} catch (IOException e) {
e.printStackTrace();
}
}
It complains about a location not being set, so I tried
FXMLLoader loader = new FXMLLoader(); loader.setLocation(UIController.class.getResource("/fxml/LoginFXML.fxml"));
However it just kept giving me the same problems. Thanks in advance.
My File Structure
https://gyazo.com/cec056fb358f453d32f49676bde12b5d
Location not set errors mean that the compiler could not find the FXML file you're referring to. I do see your FXML file is loginFXML.fxml but you're trying to load the file with a capital L: LoginFXML.fxml. This doesn't seem to have any effect in testing, but perhaps something happens with that when exporting?
This is my start function in my main class:
public void start(Stage primary) {
stage = primary;
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("UserInterface.fxml"));
try {
Parent root = (Parent) loader.load();
Scene scene = new Scene(root);
primary.setScene(scene);
}catch( Exception e) {
e.printStackTrace();
}
}
the error:
javafx.fxml.LoadException:
/C:/Users/micha/eclipse-workspace/woolard2/bin/masterfile/UserInterface.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2848)
at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2692)
at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2661)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2517)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at masterfile.Main.start(Main.java:42)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException
at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2899)
at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2846)
... 15 more
When I comment out everything in the "try" everything works and compiles, yet when I try setting the load to root it breaks.
So it is finding the file successfully, yet won't load because it can't find the class, but it's in the same folder as class and everything.... can someone please help me
edit- UserInterface.fxml -
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.Scene?>
<Scene xmlns:fx="http://javafx.com/fxml/1" fx:controller="model.UserController.java">
</Scene>
In your FXML you have defined the fx:controller property as model.UserController.java. However your class is not UserController.java, that is the name of the source file, the classname is UserController. Modify your FXML to use fx:controller="model.UserController".
My main class can't seem to find my fmxl file it seems but I'm pretty sure the pathing is correct. I don't understand what is happening.
Here is my main
public void start(Stage primaryStageObj) throws Exception{
primaryStage = primaryStageObj;
// System.out.println(getClass().getResource("/net/usikkert/kouchat/practice.fxml"));
FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/net/usikkert/kouchat/practice.fxml"));
Parent root2 = loader2.load();
System.out.println("controller set");
LoginController loginController = loader2.getController();
loginController.setArgumentParser(argumentParser);
loginController.setSettings(settings);
loginController.setUncaughtExceptionLogger(uncaughtExceptionLogger);
primaryStage.setTitle("Flake");
primaryStage.setScene(new Scene(root2, 250,439 ));
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("Perfect Version.png")));
primaryStage.show();
primaryStage.setResizable(false);
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
#Override
public void handle(WindowEvent e) {
Platform.exit();
System.exit( 0);
}
});
primaryStage.setTitle("Flake");
The error I am receiving is
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at net.usikkert.kouchat.Main.start(Main.java:74)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
... 1 more
Exception running application net.usikkert.kouchat.Main
The error at Main.java:74 is my loader call Parent root2 = loader2.load();
I don't understand what the error is caused by is my fxml file not able to be found?
That is the path of my project
Change:
FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/net/usikkert/kouchat/practice.fxml"));
to
FXMLLoader loader2 = new FXMLLoader(getClass().getResource("practice.fxml"));
I created two Tabs with Scene Builder, one fxml-file for each tab. These two files are included in an main.fxml file. In Eclipse I have one controller for each fxml file (MainController, Tab1Controller, Tab2Controller). To shorten these explanation. I want to send or load Strings one tab to the other tab via MainController (Like the mediator pattern). But i get the following error code
javafx.fxml.LoadException:
/C:/Users/.../javafxmars/Test_TabController/bin/view/Main.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2571)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at application.Main.start(Main.java:14)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2566)
... 17 more
Caused by: java.lang.NullPointerException
at controller.MainController.initialize(MainController.java:14)
... 27 more
I searching for my mistake since a few days, but i cant find my anything. I looked for the ids a several times, but nothing. The FXML loader seems alright too.
public void start(Stage primaryStage) {
try {
new FXMLLoader();
Parent root = FXMLLoader.load(getClass().getResource("/view/Main.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
The MainController looks as followed:
public class MainController {
#FXML Tab1Controller tab1controller;
#FXML Tab2Controller tab2controller;
#FXML public void initialize(){
System.out.println("Program initilized");
tab1controller.init(this);
tab2controller.init(this);
}
public String getTextloadedfromTab1() {
return tab1controller.label1.getText();
}
public void setTab2LabelText(String text) {
tab2controller.label2.setText(text);
}
}
If i have to I post the code from the two tabs or the code for the fxml files. I will be glad, if someone could help me out.
Here are the fxml documents
FXML Documents UPDATE
These project is based on these tutorial https://github.com/goranvasic/JavaFxTutorials/tree/master/JavaFxCommunicationBetweenControllers
In your main FXML you include the tabs like:
<fx:include fx:id="tab_Test1" source="tab/Tab_Test1.fxml" />
And then in your MainController you inject it like:
#FXML Tab1Controller tab1controller;
Which is not the correct way to do it. The valid name is fx:idController (fx id with a "Controller" suffix):
#FXML Tab1Controller tab_Test1Controller;
Nested Controller naming.
I am really new to javafx and trying to figure out what is what. It was going fine but then I encountered an exception.This is my code;
public void showPersonOverview() {
try {
// Load person overview.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("/AddressAppView/PersonOverview.fxml"));
AnchorPane personOverview = (AnchorPane) loader.load();
// Set person overview into the center of root layout.
rootLayout.setCenter(personOverview);
// Give the controller access to the main app.
PersonOverviewController controller = loader.getController();
controller.setMainApp(this);
} catch (IOException e) {
e.printStackTrace();
}
}
and i get an LoadExcepiton at
AnchorPane personOverview = (AnchorPane) loader.load();
anyone has any idea why?
Stack trace----
javafx.fxml.LoadException:
/home/mert/workspace/AddressApp/bin/AddressAppView/PersonOverview.fxml:25
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at AddressAppController.MainApp.showPersonOverview(MainApp.java:77)
at AddressAppController.MainApp.start(MainApp.java:47)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Can not set AddressAppController.MainApp field AddressAppView.PersonOverviewController.mainApp to javafx.scene.layout.AnchorPane
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:764)
at javafx.fxml.FXMLLoader.injectFields(FXMLLoader.java:1163)
at javafx.fxml.FXMLLoader.access$1600(FXMLLoader.java:103)
at javafx.fxml.FXMLLoader$ValueElement.processValue(FXMLLoader.java:857)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:751)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
... 13 more
Thank you.
The error message is saying that the type of a field in your controller class does not match the type declared in the fxml file. Specifically, your controller declares a field of type MainApp called mainApp, but your fxml file is trying to inject an AnchorPane into that field.