1

我做了一个小程序:

     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)它询问我权限并开始但随后加载是停了下来。错在哪里?

4

0 回答 0