我正在使用一些带有 JAVA FX 11 的绘图工具创建一个 Web 浏览 exp,但是在尝试加载具有let
和const
使用这些变量的 javascript 代码时,它们只是被忽略并抛出异常。我正在使用 maven 3.8.0、Java 1.8 和 JavaFX 11。
代码如下:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>12-ea+9</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>12-ea+9</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>12-ea+9</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>12-ea+9</version>
</dependency>
和 Java 代码
public static void main(String[] urls) {
String javaVersion = System.getProperty("java.version");
String javafxVersion = System.getProperty("javafx.version");
System.out.println(javaVersion + " java....... fx........ " + javafxVersion);
Application.launch(urls);
}
@Override
public void start(Stage stage) throws Exception {
Parameters parameters = getParameters();
List<String> raw = parameters.getRaw();
String url = "http://example.com/";
if (raw.size() != 0) {
url = raw.get(0);
}
/*
* WebConsoleListener.setDefaultListener((webView, message, lineNumber,
* sourceId) -> { System.out.println(message + "[at " + lineNumber + "] [in " +
* sourceId + "]"); });
*/
Pane root = new Pane();
WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();
// Load the Google web page
webEngine.load(url);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setTitle("IWB");
stage.show();
// mainStage = stage;
root.getChildren().add(webView);
webView.setMinSize((screenSize.getWidth() - 120), (screenSize.getHeight() - 60));
btns.setMinHeight(screenSize.getHeight() - 60);
stage.setOnCloseRequest(e -> {
// Platform.exit();
// System.exit(0);
});
// Platform.setImplicitExit(false);
}