0

What is the right way to communicate between two Controller Classes in JavaFX?

For example:

public class Controller {

  @FXML
  private Label label;

  @FXML
  private void initialize(){
      label.setText("A Label");
  }

  public void setLabelText(String labelText){
      label.setText(labelText);
  }

}

How can I call the method setLabelText() from another Controller Class without making it static?

  • instantiate a object of type controller, with its constructor method. And them controller.setLabelText. – Akin Okegbile May 30 '19 at 20:57
  • 4
    Possible duplicate of [Passing Parameters JavaFX FXML](https://stackoverflow.com/questions/14187963/passing-parameters-javafx-fxml) – Slaw May 30 '19 at 22:16

0 Answers0