I am loading scenes from FXML and store the scenes in a Deque for changing menus. The FXML files are linked to controller classes.
I want to know is there any way to access controller class (Actually controller instance) of scene from scene?
For example is there any way to do something like this:
Scene scene = scenes.getLast();
scene.getController(); //There is no such method by default
( scenes
is a Deque
that stores Scene Objects)
As fabian said, I would throw the controller into Scene#userData .
In fact I use the userData property quite a bit for managing my views, stages, etc. -- mostly as an "id" of sorts for accessing them.
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.