Java Reference
In-Depth Information
Figure 18-1
.
JavaFX application written in JavaScript
Solution 2
Write a JavaFX application using Java and embed the JavaScript application imple-
mentation using a
ScriptEngine
. The following Java class is called
CarCol-
lector.java
and it implements
javafx.application.Application
. The
Java class implements the
start()
method, which contains a
ScriptEngine
to
embed the JavaScript code that implements the application.
package org.java8recipes.chapter18.recipe18_11;
import java.io.FileReader;
import javafx.application.Application;
import javafx.stage.Stage;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;