Applets are executed within a web browser, and there's an easy way to load show a specific URL. 
Obtain a reference to the applet context 
Call the showDocument method, which takes as a parameter a URL object. 
The following code snippet shows you how this can be done.
import java.net.*;
import java.awt.*;
import java.applet.*;
public class MyApplet extends Applet
{
 // Your applet code goes here
 // Show me a page
 public void showPage ( String mypage )
 {
  URL myurl = null;
  // Create a URL object
  try
  {
   myurl = new URL ( mypage );
  }
  catch (MalformedURLException e)
  {
   // Invalid URL
  }
   
  // Show URL
  if (myurl != null)
  {
   getAppletContext().showDocument (myurl);
  }
 }
}
SOURCE : www.referjava.com
No comments:
Post a Comment