Structure Query Language, C programming, Java, Servlet, Jsp, Unix

Sunday 15 July 2012

Create an applet which has a Text Field to accept a URL string, and displays the document of the URL string in a new browser window.


[ suftApplet.java ]
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
/*
<applet code="surfApplet" height="500" width="500">
</applet>
*/
public class surfApplet extends Applet implements ActionListener
{
TextField tfURL;
Button bShowURL;
public void init()
{
tfURL = new TextField (30);
bShowURL = new Button ("Show Web");
bShowURL.addActionListener (this);
add (tfURL);
add(bShowURL);
}
public void actionPerformed (ActionEvent ae)
{
try
{
   AppletContext ac = getAppletContext();
  URL link=null;
  link = new URL ( tfURL.getText() );
    ac.showDocument (link, "_blank");
  showStatus("By Pankaj Sharma");
}
catch (Exception ex) {}
}
public void paint(Graphics g)
{
showStatus("www.master-gtu.blogspot.com");
}
}

No comments:

Post a Comment