【问题标题】:How can I use DJNativeSwing JWebBrowser as the browser for the jupyter notebook?如何使用 DJNativeSwing JWebBrowser 作为 jupyter notebook 的浏览器?
【发布时间】:2016-04-25 10:29:21
【问题描述】:

我在我的 Swing 应用程序中使用 chrriis.dj.nativeswing.swtimpl.components.JWebBrowser 打开 jupyter-notebook 的网页。现在我的问题是当我单击 New->Python 3 按钮 JWebBrowser 新建文件时,它总是返回 404 页面。

New a notebook in DJNativeSwing JWebBrowser

DJNativeSwing JWebBrowser got the 404 page

我想也许它没有执行 jupyter-notebook 中的 javascript api,谁能帮我让 DJNativeSwing JWebBrowser 在 jupyter notebook 下工作?

我使用的代码:

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

}

【问题讨论】:

  • 我不知道 jwebbrowser 使用的是什么引擎,但 Jupyter 需要一个相当现代的网络浏览器——它可能不支持 Jupyter 需要的东西。
  • java应用在windows8.1下运行,我认为它使用IE11。

标签: swing jupyter jupyter-notebook djnativeswing jwebbrowser


【解决方案1】:

谢谢Thomas K。我把jwebbrowser的引擎改成Xulrunner-24.0.en-US,问题就消失了。

【讨论】:

    猜你喜欢
    • 2018-05-26
    • 2018-07-08
    • 2016-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多