i have a FXML project and therefore a Controller class. I created an instance of a class called "Control" inside the initialize method of my Controller class.
The Problem now is: I created a second FXML Controller for a Preferences Menu and i to need access the Control object created in the main Controller class.
How do i do that?
I cannot use a simple getter, i get an error that this cannot be derefferenced from a static context.
Edit:
For the Code:
This is the main Gui Controller:
private Control control;
.
.
.
@Override
public void initialize(URL url, ResourceBundle rb) {
//Create a Controller
control = new Control(0);
.
.
.
}
The second FXML is loaded within this handler:
@FXML
public void handleSetPreferences(ActionEvent ae) throws Exception {
Group root = new Group();
Stage stage = new Stage();
BorderPane frame = FXMLLoader.load(getClass().getResource("guipreferences.fxml"));
root.getChildren().add(frame);
Scene scene = new Scene(root);
stage.initStyle(StageStyle.UNDECORATED);//disables the OS frame
stage.initStyle(StageStyle.TRANSPARENT);
stage.setScene(scene);
stage.show();
}
I need to access the control object created within the first Controller from the Controller created with the handle above.