Show HTML file in JEditorPane

被刻印的时光 ゝ 提交于 2019-11-28 02:04:48
Andrew Thompson

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.

trashgod

Support for HTML in Swing Components is limited to 3.2, predating the <object> tag. You might be able to use a HyperlinkListener, illustrated here, in conjunction with Desktop#browse(). See also this example.

To render html content from local file, the local file's extension must be ".html". JEditor Pane will render "content.html" but will not render "content.txt".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!