I have a multi scene JavaFX FXML application based on Angela Caicedo code https://blogs.oracle.com/acaicedo/entry/managing_multiple_screens_in_javafx1
I have added a TextField
to Scene2.fxml
and Scene3.fxml
files each scene has
its own Controller
Class with a ScreensController
class that loads a HashMap
with
Id name
, Node screen
that is defined in the ScreensFramework
class (Main
class)
public void addScreen(String name, Node screen) {
screens.put(name, screen);
}
So each time you click a Button
on a screen (scene) you fire an ActionEvent
and move to another screen
myController.setScreen(ScreensFramework.screen2ID);
What I would like to do if it is possible is use the value in the TextField
on Screen2
and transfer it to the TextField
on Scene3. I have discovered that unless both FXML
files are loaded this is so far not possible. This is a desktop application.
So how do you create a variable that is GLOBAL and has a life after one class is
unloaded or one FXML file is unloaded?
At this point I do not want a database to accomplish this task.
I have developed in Visual Basic 6 where I would just declare a global variable that
could be used through out the application.