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.
Sounds like you were thinking of the JEditorPane
. It can display html from e.g. an URL.
Swing tutorial, Editor panes.
The support for javascript is nonexistent.
You can try out third party components such as flying-saucer, which is a XML/XHTML and CSS 2.1 renderer in pure Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With