How do I pass a variable between JavaFX to javaScript?
<p>How do I pass variable from Java(JavaFx) to JavaScript? I think I have to use <code>executeScript</code>, but I am not sure how to really use it.  Basically I want to a program that sends elements in <code>arraylist</code> from java into the <code>array</code> in javaScript. The code below is the Java code that I wrote. Hope someone could help me out. Thank you in advance. </p>

<pre><code>import java.util.ArrayList;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class UserInterface extends Application{
    Button btn_js;

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        WebView myWebView = new WebView();
        WebEngine engine = myWebView.getEngine();
        ArrayList&lt;String&gt; arr = new ArrayList&lt;String&gt;();
        btn_js = new Button("fire js");
        btn_js.setOnAction(new EventHandler&lt;ActionEvent&gt;() {

            @Override
            public void handle(ActionEvent event) {
                //engine.executeScript("something goes here to transfer data to js");
        }
        });
        VBox root = new VBox();
        root.getChildren().addAll(myWebView, btn_js);
        Scene scene = new Scene(root, 500, 500);
        stage.setScene(scene);
        stage.show();
    }
}
</code></pre>