在显示HTML的JEditorPane文件 [英] Show HTML file in JEditorPane

查看:212
本文介绍了在显示HTML的JEditorPane文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作中,我要显示HTML文件的Swing应用程序。

我使用它的JEditorPane 控制。它是作为最初显示的HTML文件的内容,但不以相同的格式在实际的HTML文件。

的JEditorPane 不支持对象元素。而不是在加载对象文件,它只是显示

有没有摆任何其他内置的控制浏览HTML文件,而不是的JEditorPane

我用下面的code:

 的JEditorPane HtmlPane =新的JEditorPane();
文件文件1 =新的文件(文件路径);
HtmlPane.setContentType(text / html的);
HtmlPane.setEditable(假);
HtmlPane.setPage(file1.toURI()的toURL());
JScrollPane的JSP =新JScrollPane的(HtmlPane);


解决方案

在核心更先进的HTML渲染你最好的赌注Java是使用基于JavaFX的的WebView 组件作为在添加HTML内容JavaFX应用的描述的。它支持HTML5,但我没有真正发挥它,所以我不能说有多好呈现HTML。

注意,Java FX有效是摆动的替代,但AFAIU的Java FX组分可以嵌入摆动的GUI。

I am working on a Swing application in which I have to show HTML files.

I am using JEditorPane control for it. It is showing the content of HTML file but not in the same format as originally in the actual HTML file.

JEditorPane does not support the object element. Rather than loading the object file its just showing ?.

Is there any other inbuilt control in Swing to browse the HTML file rather than JEditorPane?

I am using the following code:

JEditorPane HtmlPane= new JEditorPane();
File file1= new File("path of the file");
HtmlPane.setContentType("text/html");
HtmlPane.setEditable(false);
HtmlPane.setPage(file1.toURI().toURL());
JScrollPane jsp=new JScrollPane(HtmlPane);

解决方案

Your best bet for more advanced HTML rendering in core Java is to use the JavaFX based WebView component as described in Adding HTML Content to JavaFX Applications. It supports HTML5, but I've not actually played with it, so I cannot say how well it renders HTML.

Note that Java FX is effectively an alternative to Swing, but AFAIU Java FX components can be embedded in Swing GUIs.

这篇关于在显示HTML的JEditorPane文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆