0

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.

Avinta
  • 678
  • 1
  • 9
  • 26
  • 1
    Please show some code. How are you loading the second FXML? With an `FXMLLoader` in an event handler? Or with an ``? Your question is probably answered by http://stackoverflow.com/questions/14187963/passing-parameters-javafx-fxml/14190310#14190310 – James_D Jan 28 '15 at 22:52
  • 1
    Thanks for the update. This is definitely addressed by the [question I linked in the previous comment](http://stackoverflow.com/questions/14187963/passing-parameters-javafx-fxml/14190310#14190310) – James_D Jan 29 '15 at 00:09
  • That did the job...thank you :) – Avinta Jan 29 '15 at 19:18

0 Answers0