【问题标题】:Webview does not display anything in JFrame paneWebview 在 JFrame 窗格中不显示任何内容
【发布时间】:2017-11-07 05:05:41
【问题描述】:

在我的JFrame 窗格中,我想显示一个webview,类的decare 是:

public class MainTabbedForm extends javax.swing.JFrame {

我添加了一个名为Display WebButton,这是它的代码:

        private void siteSurveyActionPerformed(java.awt.event.ActionEvent evt) {                                           
JFrame myFrame = new JFrame();
JFXPanel myFXPanel = new JFXPanel();
myFrame.add(myFXPanel);    
  Platform.runLater(() -> {
      BorderPane borderPane = new BorderPane();
      WebView webComponent = new WebView();

      webComponent.getEngine().load("http://google.com/");

      borderPane.setCenter(webComponent);
      Scene scene = new Scene(borderPane,450,450);
      myFXPanel.setScene(scene);
});

    }      

但是当我运行程序并按下Display Web 按钮时,它什么也没做! Netbeans 输出显示中没有任何内容,没有错误或任何内容。 我哪里做错了?

【问题讨论】:

    标签: java swing javafx webview


    【解决方案1】:

    你不见了

    myFrame.setVisible(true);
    

    【讨论】:

    • 谢谢先生,我还有一个问题,我想问它,但在想知道之前。我的 Webview 正在显示我本地主机上的页面。它需要身份验证。 (当我在浏览器中访问该页面时,浏览器需要用户和密码,所以当我从 java 运行时,webview 显示 401 Unauthorized,是否可以显示它?
    • @me_the_seven:这是个新问题;寻找HttpClient
    • @trashgod 我刚刚问过stackoverflow.com/questions/44387512/…
    • @James_D 恭喜达到 >100k
    • @mKorbel 谢谢。你也是:)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-29
    • 1970-01-01
    • 2020-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多