程序问问:applet浏览指定URL
import *;import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.AppletContext;
import javax.swing.*;
import javax.swing.event.*;
public class ShowDocument extends JApplet{
public void init()
{
JButton goButton =new JButton("Link to www.);
Container myContainer=getContentPane();
myContainer.add(new JLabel("Link to SOHU"),BorderLayout.NORTH);
myContainer.add(goButton,BorderLayout.SOUTH);
goButton.addActionListener(new ButtonListener());
}
class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try
{
URL newDocument=new URL("http://www.);
AppletContext browser=getAppletContext();
browser.showDocument(newDocument);
}
catch(Exception URLException)
{}
}
}
}
这个程序的作用是什么?不是可以从链接打开搜狐网站吗?我点击Link to www.链接是,怎么弹不出该网页呀?