There are some good ways to do this:
- Create a reference of a Controller
private ControllerClass controller;
/*...
Parent root;
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("/path/ofYourFxml.fxml"));
controller = fxmlloader.getController();
//Now you can use a method like getter and setter to set or get any value of variable
controller.yourMethodToCall()
Stage stage = new Stage();
stage.setScene(new Scene(root, 1200, 700));
stage.show()
- For dirt and dirty solution: declare any variable you want to use in other class as static (Not recommended for a complex application(static problem))
- Use a shared data Model among Controllers
Explaination follows...
No comments:
Post a Comment