如何在Java Swing中的JPanel中呈现基本的HTML标记? [英] How to render basic HTML markup inside a JPanel in Java Swing?

查看:696
本文介绍了如何在Java Swing中的JPanel中呈现基本的HTML标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



  JPanel htmlPanel = new HtmlPanel(< html>< body>< h1> hello world< / h1>< / body>< / html>); 

我认为我在某处看过这样的代码。那么CSS和JS呢? JPanel可以轻松支持这个吗?有没有库可以做我要求的内容? 解决方案

检查 JEditorPane中,以查看如何将CSS支持添加到 JEditorPane 即可。您需要 HTMLEditorKit



我不明白为什么您需要JavaScript支持JEditorPane。它的基本用途是呈现以HTML和CSS编写的帮助页面。



如果您需要将真正的McCoy嵌入您的应用程序中,请尝试 Lobo Java Web浏览器。 Lobo开发JavaScript和CSS,并且开源100%Java。



2015年11月:Lobo浏览器的最新版本是 Lobo Evolution

I want to do something really simple like this:

JPanel htmlPanel = new HtmlPanel("<html><body><h1>hello world</h1></body></html>");

I think I had seen code somewhere that did exactly this. What about CSS and JS? Can the JPanel be made to support this easily? Are there libraries somewhere that do what I am asking for?

解决方案

Check here to see how to add CSS support to your JEditorPane. You will need an HTMLEditorKit.

I do not see why you would need JavaScript support for a JEditorPane. The basic use of it is to render Help pages written in HTML and CSS.

If you need to have the real McCoy embedded into your application, try the Lobo Java Web Browser. Lobo does JavaScript and CSS and is open source 100% Java.

November 2015: The latest fork of the Lobo Browser is Lobo Evolution.

这篇关于如何在Java Swing中的JPanel中呈现基本的HTML标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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