Discussion Locked

rendering HTML from java apps/applet

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

We are using JDK1.2.2, how would we develop an application or an applet that can read an HTML file and render it in a browser - a la the HTML control available in the microsoft world with VJ++.

We are still looking to render on a windows PC usingIE.

3 replies

by duganjc73

This is from a Java TechMail that I just read. ---

Opening a new Web page from a Java applet
Want a simple way to open a Web page in Java? Use the showDocument method to instruct the browser to load a new page.

The showDocument method tells the browser to load the Web page pointed to by the URL you supply. The following sample code loads TechRepublic's Web site into the browser:
try {
// create a URL for your call to showDocument
URL url= new URL("https://www.techrepublic.com");
// tell the browser to load your web page
getAppletContext().showDocument(url);
}
catch(MalformedURLException e) {
showStatus("URL not found");
}

When creating a new URL, Java requires that any MalformedURLExceptions be caught, so we enclosed our code in a try/catch construct.

I hope this helps...

This discussion is closed to new replies.