简体   繁体   English

JavaFX 网页视图

[英]JavaFX Web View

I want to code a small web browser using JavaFX Web View.我想使用 JavaFX Web View 编写一个小型 Web 浏览器。 Here's my current code:这是我当前的代码:

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();

    }
}

When I want to compile it using当我想使用编译它时

javac -p /Users/xamsoftware/javafx-sdk-11.0.2/lib --add-modules=javafx.controls WebViewExample.java

It says它说

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

Is there anybody that can help me?有没有人可以帮助我?

因此,响应一条评论,您基本上必须将--add-modules=javafx.controls--add-modules=javafx.web

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么.jar可执行文件无法在JavaFX(Java)中加载Web视图? - Why .jar executable doesn't load web view in javafx (java)? Javafx Web 11 - 初始化 QuantumRenderer 时出错:找不到合适的管道 - Javafx Web 11 - Error initializing QuantumRenderer: no suitable pipeline found 如何在javafx中设置webview? - How to setup webview in javafx? Java Swing 应用程序中的简单 JavaFX WebView 不显示内容 - Simple JavaFX WebView in Java Swing app not displaying contents 无法使用 javaFx Webview 在网页中显示视频(视频在给定的 url 上直播) - Unable to display video in webpage using javaFx Webview (video is live on the given url) 使用基于Web的文本编辑器(例如在WebView内加载的summernote)时无法加载图像 - Can't load images when using a web-based text editor like summernote loaded inside a WebView #javafx 在JavaFX中静音WebView,有可能吗? - Mute a WebView in JavaFX, is it possible? JavaFX在FX Application线程之外的另一个线程中运行WebEngine - JavaFX Running WebEngine in another thread than FX Application Thread Why I'm unable to invoke Java methods from html content via the JavaScript call in JavaFX WebView? - Why I'm unable to invoke Java methods from html content via the JavaScript call in JavaFX WebView? 如何设置 JavaFX WebView 的编码? - How can I set the encoding of a JavaFX WebView?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM