如何使用DJNativeSwing JWebBrowser作为jupyter笔记本的浏览器



我在我的swing应用程序中使用chrriis.dj.nativeswing.swtimpl.components.JWebBrowser来打开jupyter-notebook的网页。现在我的问题是当我单击New->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();
  }
}

谢谢托马斯·我将jwebbrowser的引擎更改为Xulrunner-24.0.en-US,问题消失了。

相关内容

  • 没有找到相关文章