Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

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); 
                } 
        } 
} 
Posted By: Name:Rajesh Kr URL: How do you load an HTML page from an Applet ?