java - 在 Java GUI 中显示 HTML/CSS

标签 java html css desktop-application

这是我要显示的 html: http://boba.dyndns-server.com/Degrees/Art_History_Track_BA.html

我也想显示这个 google calendar以及。 (但是这个链接不是优先级)

我查看了 DJProject它似乎需要 win32 计算机,但我希望该程序能够在 mac 和 windows 上运行。如果我对 DJProject 的理解有误,你能解释一下如何实现他们的 Simple Example 吗?在 Mac 上使用 Eclipse。

我的目标是将链接嵌入到 JScrollPanel 中,开销尽可能小。 感谢您提出的所有建议。

**JEditor Pane 可以显示html,但不能显示htmls 中带有css 的html。

***如果你知道移除 css,我也想考虑一下

** 我要显示的 html 是由 pdf 转换器生成的。

最佳答案

您可以直接使用 SWT 浏览器:


import org.eclipse.swt.*;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class Main {
    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        Browser browser = new Browser(shell, SWT.NONE);
        browser.setUrl("http://printf.ru/");
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }
}

定制:http://www.eclipse.org/swt/snippets/
完整教程:http://www.eclipse.org/articles/Article-SWT-browser-widget/browser.html

关于java - 在 Java GUI 中显示 HTML/CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5341303/

相关文章:

java - Jsoup 选择包含 html 标签的文本

html - CSS:最小高度为 100% 的 div 中的居中文本溢出其边界

javascript - Plupload 与 Bootstrap 冲突

javascript - 将 Html 作为参数从 javascript 发送到 asp.net mvc Controller

php - 如何在我的元素中绘制饼图

jquery - 如何在每个第三表行中设置某些 td 的样式?

java - 如何创建一个通知服务器,在数据库更改时通知 Delphi 应用程序?

java - cassandra 中的批量加载器 : String as row keys in cassandra

java - 使用从 zip 文件中的文件名派生的特殊字符

html - 使用固定位置和相对位置制作 Web 布局时遇到问题