开发者

Webkit browser in a Java app

I was wondering if there was a Java swing component that uses webkit.开发者_如何学Go Is it possible to create a webkit browser in Java - must I use JavaFX ?


There is one in development by Swing Team: http://weblogs.java.net/blog/ixmal/archive/2008/05/introducing_jwe.html


JCEF

JCEF (Java Wrapper for the Chromium Embedded Framework) is a Java wrapper around CEF, which is in turn a wrapper around Chrome:

  • https://code.google.com/p/javachromiumembedded/
  • https://code.google.com/p/chromiumembedded/

Both projects seem quite active and the browser rendering is much faster than JavaFX's WebView (at least with JDK 8u20).

JFXPanel

It is also possible to use the JavaFX WebView in a Swing application via the JFXPanel.

public class JavaFxWebBrowser extends JFXPanel {
    private WebView webView;
    private WebEngine webEngine;

    public JavaFxWebBrowser() {
        Platform.runLater(() -> {
            initialiseJavaFXScene();
        });
    }

    private void initialiseJavaFXScene() {
        webView = new WebView();
        webEngine = webView.getEngine();
        webEngine.load("http://stackoverflow.com");

        Scene scene = new Scene(webView);
        setScene(scene);
    }
}


You can also look at cross-platform JxBrowser Java library that allows embedding Chromium-based web browser control into Java AWT/Swing application. The library is developer by the company I'm working for.

It supports both Java Swing and JavaFX.

BTW: the browser control is totally lightweight. All rendering happens in a separate native process by native Chromium engine. The web page looks like it's displayed in Google Chrome.


I develop this browser for my college project may be this helpful for you

My Button is open source java web browser.

Develop for school and college projects and learning purpose. Download source code extract .zip file and copy “mybutton” folder from “parser\mybutton” to C:\

Import project “omtMyButton” in eclipse. Require Java 6.

Download .exe and source code : https://sourceforge.net/projects/omtmybutton/files/


SWT has support built-in for GWT, Windows, and OS X. Support for GWT and OS X will probably be less substantial than for Windows.

http://lists.macosforge.org/pipermail/webkit-help/2009-December/000548.html

XULRunner probably has much better API access between Java and the DOM.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜