We have an applet code below. where we have specified a button and when the button is clicked it should open a new website. Yahoo website in this case. The code for the applet is below
public class GotoLinkApplet extends Applet implements ActionListener{
public void init()
{
String link="yahoo";
Button b=new Button(link);
b.addActionListener(this);
add(b);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.out.println("1");
Button src= (Button)e.getSource();
String link="http://www."+src.getLabel()+".com";
try{
AppletContext a=getAppletContext();
URL url =new URL(link);
//a.showDocument(url, "_self");
a.showDocument(url, "_blank");
System.out.println("a");
}
catch(MalformedURLException ae)
{
System.out.println(ae.getMessage());
}
}
}
We executed the above code in eclipse,but when we click on the button, the yahoo link is not coming up. Request you to help. But the code that specifies showdocument runs fine.
Any help on the above is much appreciated.