有没有办法在 Java 中嵌入浏览器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48249/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 07:38:49  来源:igfitidea点击:

Is there a way to embed a browser in Java?

javabrowsercross-platform

提问by Ande Turner

Is there a way to embed a browser in Java? more specifically, is there a library that can emulate a browser?

有没有办法在 Java 中嵌入浏览器?更具体地说,是否有可以模拟浏览器的库?

采纳答案by OscarRyz

Since JavaFX 2.0 you can use now webview

从 JavaFX 2.0 开始,您现在可以使用webview

enter image description here

在此处输入图片说明

回答by Bart

You can try Webrendereror Ice Browser

你可以试试WebrendererIce Browser

回答by Jimmy

I believe JWebPane is going to be the official way to embed a browser into a java app. Its based on the open sourced engine - WebKit, which is used in Apples Safari and Googles Chrome browsers.See this blogfor details.

我相信 JWebPane 将成为将浏览器嵌入 Java 应用程序的官方方式。它基于开源引擎 - WebKit,用于 Apples Safari 和 Googles Chrome 浏览器。有关详细信息,请参阅此博客

回答by alexmcchessers

You could use SWTfor your GUI. Its Browser control allows you to embed IE, Mozilla or Safari (depending on the platform you're running in) with little pain.

您可以将SWT用于您的 GUI。它的浏览器控件允许您轻松嵌入 IE、Mozilla 或 Safari(取决于您运行的平台)。

回答by Eddie

I have successfully opened a browser from Java using SWT. You can find code examplesof how to use SWT to open a Browser window. It's very easy to do.

我已使用SWT从 Java 成功打开浏览器。您可以找到有关如何使用 SWT 打开浏览器窗口的代码示例。这很容易做到。

回答by Uri

By far the most robust embeddable browser I am familiar with is the one in SWT. In fact, it is so flexible that the JavaDoc hover you can see in Eclipse is actually a browser, and the JavaDoc view actually supports things like animation!

迄今为止,我熟悉的最强大的可嵌入浏览器是 SWT 中的浏览器。事实上,它是如此灵活,以至于您在 Eclipse 中看到的 JavaDoc 悬停实际上是一个浏览器,而 JavaDoc 视图实际上支持动画之类的东西!

The only risk with using SWT is that there are different versions of the SWT library for different platforms. I'm not sure if there is a singl jar you could include to cover everyone.

使用 SWT 的唯一风险是针对不同平台有不同版本的 SWT 库。我不确定是否有一个单独的罐子可以包含在每个人身上。

回答by McDowell

You can embed a browser in a Swing/AWT GUI using the JDICAPI. I don't see any mention of OS X, so it may not be of use to you.

您可以使用JDICAPI在 Swing/AWT GUI 中嵌入浏览器。我没有看到任何提及 OS X 的内容,因此它可能对您没有用。

回答by OscarRyz

You may try this: https://jdic.dev.java.net/

你可以试试这个:https: //jdic.dev.java.net/

alt text
(source: java.net)

替代文字
(来源:java.net

Or this: http://lobobrowser.org/java-browser.jsp

或者这个:http: //lobobrowser.org/java-browser.jsp

alt text
(source: lobobrowser.org)

替代文字
(来源:lobobrowser.org

回答by Horcrux7

If you need a pure Java solution then you can try JWebEngine. It render HTML 4 very good. You can use it in an applet, Java webstart and on any platform. The using is very simple.

如果您需要纯 Java 解决方案,那么您可以尝试JWebEngine。它呈现 HTML 4 非常好。您可以在小程序、Java webstart 和任何平台上使用它。使用非常简单。

回答by h3xStream

JxBrowserhas not been mentionned yet. It embed either Mozilla Firefox (Gecko), Apple Safari (WebKit) or Internet Explorer. Programmer's Guide

尚未提及 JxBrowser。它嵌入了 Mozilla Firefox (Gecko)、Apple Safari (WebKit) 或 Internet Explorer。程序员指南