0

I am using chrriis.dj.nativeswing.swtimpl.components.JWebBrowser in my swing application to open web page of a jupyter-notebook. Now my problem is when I click New->Python 3 button JWebBrowser to new a file, it always return the 404 page.

New a notebook in DJNativeSwing JWebBrowser

DJNativeSwing JWebBrowser got the 404 page

I think maybe it did not execute the javascript api in jupyter-notebook, can anyone help me make the DJNativeSwing JWebBrowser work under jupyter notebook?

The code I used:

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

}
  • I don't know what engine jwebbrowser is using, but Jupyter requires a fairly modern web browser - it's possible that it doesn't support something Jupyter needs. – Thomas K Apr 25 '16 at 11:49
  • The java app ran under windows8.1, I think it use IE11. – Kan Liu Apr 26 '16 at 01:36

1 Answers1

0

Thanks Thomas K. I changed the engine of jwebbrowser to Xulrunner-24.0.en-US and the problem disappeared.

Community
  • 1
  • 1