【发布时间】:2020-11-18 10:21:32
【问题描述】:
我想使用 JavaFX Web View 编写一个小型 Web 浏览器。这是我当前的代码:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class WebViewExample extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) {
primaryStage.setTitle("JavaFX WebView Example");
WebView webView = new WebView();
webView.getEngine().load("http://google.com");
VBox vBox = new VBox(webView);
Scene scene = new Scene(vBox, 960, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
}
当我想编译时使用
javac -p /Users/xamsoftware/javafx-sdk-11.0.2/lib --add-modules=javafx.controls WebViewExample.java
它说
WebViewExample.java:4: error: package javafx.scene.web is not visible
import javafx.scene.web.WebView;
^
(package javafx.scene.web is declared in module javafx.web, which is not in the module graph)
1 error
有没有人可以帮助我?
【问题讨论】:
-
尝试将
--add-modules=javafx.controls更改为--add-modules=javafx.web
标签: javafx-webview