簡體   English   中英

如何使用DJNativeSwing JWebBrowser作為jupyter筆記本的瀏覽器?

[英]How can I use DJNativeSwing JWebBrowser as the browser for the jupyter notebook?

我在我的swing應用程序中使用chrriis.dj.nativeswing.swtimpl.components.JWebBrowser打開Jupyter筆記本的網頁。 現在我的問題是,當我單擊“新建”->“ Python 3”按鈕JWebBrowser來新建文件時,它總是返回404頁面。

在DJNativeSwing JWebBrowser中新建一個筆記本

DJNativeSwing JWebBrowser獲得了404頁

我認為也許它沒有執行jupyter-notebook中的javascript api,有人可以幫助我使DJNativeSwing JWebBrowser在jupyter筆記本下工作嗎?

我使用的代碼:

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;

import chrriis.common.UIUtils;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowserWindow;
import chrriis.dj.nativeswing.swtimpl.components.WebBrowserAdapter;
import chrriis.dj.nativeswing.swtimpl.components.WebBrowserNavigationEvent;
import chrriis.dj.nativeswing.swtimpl.components.WebBrowserWindowFactory;
import chrriis.dj.nativeswing.swtimpl.components.WebBrowserWindowWillOpenEvent;

/**
 * @author Christopher Deckers
 */
public class NavigationControl extends JPanel {

  protected static final String LS = System.getProperty("line.separator");

  public NavigationControl() {
    super(new BorderLayout());
    final JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    final JWebBrowser webBrowser = new JWebBrowser();
    webBrowser.setBarsVisible(false);
    webBrowser.setStatusBarVisible(true);
    webBrowser.navigate("https://try.jupyter.org/");  

    tabbedPane.addTab("Controled Browser", webBrowser);
    add(tabbedPane, BorderLayout.CENTER);
  }

  /* Standard main method to try that test as a standalone application. */
  public static void main(String[] args) {
    UIUtils.setPreferredLookAndFeel();
    NativeInterface.open();
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        JFrame frame = new JFrame("DJ Native Swing Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new NavigationControl(), BorderLayout.CENTER);
        frame.setSize(800, 600);
        frame.setLocationByPlatform(true);
        frame.setVisible(true);
      }
    });
    NativeInterface.runEventPump();
  }

}

感謝Thomas K。 我將jwebbrowser的引擎更改為Xulrunner-24.0.en-US,問題消失了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM