Today when I was working on Windows, there was no problem at all. After transferring to my Mac at home, trouble started.
I have the following path in the FXML (BorderPane):
fx:controller="application.controllers.DashboardController"
The directory structure looks like this:
Eclipse keeps saying that 'the controller has no field XXX'.
It seems to me quite clear that they are there!
The interface gets properly loaded when run, I'm quite sure the path is correct.
However, the controller is not recognised, and 'test' doesn't get printed.
Any hints?
FXML loader and IDEs (eg Eclipse) use reflection to retrieve information about the controller. In your case you seem to have an inner class PleaseProvideControllerClassName
where the annotated fields are. Hence, from reflection's perspective the DashboardController
class itself does not contain any fields at all.
It's worth noting that nested classes should not be used in controllers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.