Swing's JEditoryPane is capable of displaying html 3.0. If you are willing to require the users to already have or to download swing (it's a couple MB) then this is the easiest option:
JEditorPane disp = new JEditorPane("text/html", html_text); disp.setEditable(false);
Actually some are starting to come out. One you can try and use is the JavaBrowser - this is really a mini web browser written in Java and therefore contains a simple (but usable) display engine. You should be able to extract the necessary parts from there. Another option is the ICE Browser which offers better html support, but is not free for commercial use. A third possiblity is to use Netscape's IFCs - this also contains an html displayer, but the whole thing is rather large. Note that the JavaBrowser and Netscape's IFCs only display simple HTML (something like HTML 1.0), so you can't display fancy things like tables (you'll have to use the ICE Browser or write your own code for that).
You can POST (or PUT) your html to a server (e.g. using URLConnection) and have the server put the html in a file; then use AppletContext.showDocument() to retrieve that file and have it displayed in a new window (or frame).
Another possibility for very short html is to put the html in the query string of a url which is fetched via a showDocument(); the url itself then points to a simple echo cgi-script which returns the query string.
When you click on either button it will cause the browser to display
the html code in the corresponding text field as a new document.
The LiveConnect button does this via the LiveScript support,
and the showDocument() button via the applet context's
showDocument() method given a
Here is the whole Applet:
<APPLET CODE="JScriptExample.class" WIDTH=500 HEIGHT=80 MAYSCRIPT> </APPLET>
Paul Houle also has a nice demonstration of how to use LiveConnect; if you have trouble with the above example you might want to try his instead. It's similar, except that is uses the eval() call to open a window, write to it, and then close it.