Java 应用程序中的 Webkit 浏览器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2492540/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Webkit browser in a Java app
提问by just_a_dude
I was wondering if there was a Java swing component that uses webkit. Is it possible to create a webkit browser in Java - must I use JavaFX ?
我想知道是否有使用 webkit 的 Java swing 组件。是否可以在 Java 中创建 webkit 浏览器 - 我必须使用 JavaFX 吗?
采纳答案by Eugene Ryzhikov
There is one in development by Swing Team: http://weblogs.java.net/blog/ixmal/archive/2008/05/introducing_jwe.html
Swing 团队正在开发一个:http: //weblogs.java.net/blog/ixmal/archive/2008/05/introducing_jwe.html
回答by dt.
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.
SWT 内置了对 GWT、Windows 和 OS X 的支持。对 GWT 和 OS X 的支持可能不如 Windows。
http://lists.macosforge.org/pipermail/webkit-help/2009-December/000548.html
http://lists.macosforge.org/pipermail/webkit-help/2009-December/000548.html
XULRunner probably has much better API access between Java and the DOM.
XULRunner 可能在 Java 和 DOM 之间有更好的 API 访问。
回答by Dhiral Pandya
I develop this browser for my college project may be this helpful for you
我为我的大学项目开发了这个浏览器可能对你有帮助
My Button is open source java web browser.
My Button 是开源的 Java 网络浏览器。
Develop for school and college projects and learning purpose. Download source code extract .zip file and copy “mybutton” folder from “parser\mybutton” to C:\
为学校和大学项目和学习目的而开发。下载源代码解压 .zip 文件并将“mybutton”文件夹从“parser\mybutton”复制到 C:\
Import project “omtMyButton” in eclipse. Require Java 6.
在 Eclipse 中导入项目“omtMyButton”。需要 Java 6。
Download .exe and source code : https://sourceforge.net/projects/omtmybutton/files/
下载 .exe 和源代码:https: //sourceforge.net/projects/omtmybutton/files/
回答by Vladimir
You can also look at cross-platform JxBrowserJava 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.
您还可以查看跨平台JxBrowserJava 库,该库允许将基于 Chromium 的 Web 浏览器控件嵌入到 Java AWT/Swing 应用程序中。该库是我工作的公司的开发人员。
It supports both Java Swing and JavaFX.
它同时支持 Java Swing 和 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.
顺便说一句:浏览器控件是完全轻量级的。所有渲染都由原生 Chromium 引擎在单独的原生进程中进行。该网页看起来像是在 Google Chrome 中显示的。
回答by Luke Quinane
JCEF
联合基金
JCEF (Java Wrapper for the Chromium Embedded Framework)is a Java wrapper around CEF, which is in turn a wrapper around Chrome:
JCEF(Chromium Embedded Framework 的 Java Wrapper)是 CEF 的 Java 包装器,而 CEF 又是 Chrome 的包装器:
Both projects seem quite active and the browser rendering is much faster than JavaFX's WebView (at least with JDK 8u20).
这两个项目看起来都很活跃,浏览器渲染比 JavaFX 的 WebView 快得多(至少在 JDK 8u20 中)。
JFXPanel
JFX面板
It is also possible to use the JavaFX WebView in a Swing application via the JFXPanel.
也可以通过 JFXPanel 在 Swing 应用程序中使用 JavaFX WebView。
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);
}
}