Last updated 2004-06-28 by Roedy
Green ©1996-2004 Canadian Mind Products
Java definitions: 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
You are here : home : Java Glossary : H words : HTML Rendering.
java.net.URL url = new java.net.URL ( "http://mindprod.com" ); getAppletContext().showDocument(url );
That code will fail with a NullPointerException if you attempt it in an application. You can catch all exceptions and just ignore the request in code that sometimes runs as an Applet and sometimes as an application.
There are some catches:
In Java 1.2 there is javax.swing.text.HTMLEditorKit. which offers primitive HTML 3.2 rendering ability, inching toward HTML 4 compatibility. You use it like this:
output = new JEditorPane(); output.setContentType( "text/html" ); output.setEditable( false );
From then on text in the pane is rendered as HTML. You can also use
output.setPage( "http://mindprod.com" );
to render a page.
In older JVMs, if you are writing an application you are SOL. For applications, there is no standard HTML rendering class, though BISS-AWT has some primitive HTML rendering code. Andrew Moulden offshore@netcomuk.co.uk has also written Calpane an HTML rendering class, based on Swing.
BrowserLauncher works on Mac and Windows only to launch the default browser from an application. This is useful to implement the help files as HTML.
You can use exec to launch a browser from an application. You can specify the particular browser or use the url form to let Windows decide which browser to use. Just feed a URL string to the Windows command processor.
home |
Canadian Mind Products | |||
| mindprod.com IP:[24.87.56.253] | ||||
| Your IP:[80.134.30.163] | ||||
| You are visitor number 2924. | ||||
| Please send errors, omissions and suggestions | ||||
| to improve this page to Roedy Green. | ||||
| You can get a fresh copy of this page from: | or possibly from your local J: drive mirror: | |||
| http://mindprod.com/jgloss/htmlrendering.html | J:\mindprod\jgloss\htmlrendering.html | |||