How do you load an HTML page from an Applet ?

How do you load an HTML page from an Applet ?

Applets are loaded and executed within a web browser, and hence you can load specific URL.

 * Get a reference to the applet context * Call the showDocument method with a URL object as parameter.

 The following code can help here: import java.applet.*;

 public class MyApplet extends Applet { // Applet code here // load an html page public void showPage (String aPage) //aPage should contained address of the HTML page to be shown { URL url = null; try { url = new URL (aPage); } catch (MalformedURLException e) { //handle exception } if (url != null) { getAppletContext().showDocument (url); } } }


By:Jalees
Date:2013-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher