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