1

My program is structured package as follows -Browser.fxml -Elements.fxml

+BrowserController : Browser transmit values url to Elements

@FXML
void txtURL(ActionEvent event) {
    Pane pnLoad = fxmlLoader.load(getClass().getResource("Elements.fxml").openStream());
    FunctionController controller = (FunctionController) fxmlLoader.getController();
    controller.viewURL(txtURL.getText()); 
}

+ElementsController :, -With reading after I can only use the value url once for function viewURL

    @FXML
    public void viewURL(String url) {
        System.out.println(url);
    }

+How can I use the url again?

    @FXML
    void btnReviewUrl(ActionEvent event) {
      System.out.println(url);
    }

Please help me!

Touya Akira
  • 301
  • 4
  • 14

1 Answers1

3

You can create a Static variable in your class and assign the url value to that variable to ve used again anf across classes

 public static String urlValue;

@FXML
public void viewURL(String url) {
    System.out.println(url);
    urlValue =  url;
}
Rahul Singh
  • 19,030
  • 11
  • 64
  • 86