我制作了一个小程序:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import Java.io.*;
public class a extends JApplet
{
public void init()
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
add (new MaxC());
}
});
}
}
class MaxC extends JPanel
{
public MaxC()
{
maxlink = new JTextField(40);
JButton download = new JButton("Pobierz");
JButton play = new JButton("Odtwórz online");
download.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
try
{
URL url = new URL("http://www.google.com");
InputStream response = url.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(response));
for (String line; (line = reader.readLine()) != null;)
{
maxlink.setText("yes");
}
reader.close();
}
catch (Exception e) {maxlink.setText(""+e);}
}
});
add(maxlink);
add(download);
add(play);
}
public JTextField maxlink;
}
它在Firefox和AppletViewer中工作,但是当我签名时它无法正常工作(http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html) 它问我有关权限和启动但然后停止加载。错误在哪里?