package applet;import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.net.*;
/**
 * Title:
 * Description:
 * Copyright:    Copyright (c) 2002
 * Company:
 * @author
 * @version 1.0
 */public class Applet1 extends JApplet
{
    boolean isStandalone = false;
    /**Get a parameter value*/
    public String getParameter(String key, String def)
    {
        return isStandalone ? System.getProperty(key, def) :
            (getParameter(key) != null ? getParameter(key) : def);
    }    String ip = "bbbb";
    String ip1 = "cccc";
    String ip2 = "dddd";
    String ip3 = "eeee";
    String ip4 = "ffff";
    /**Construct the applet*/
    public Applet1()
    {
    }
    /**Initialize the applet*/
    public void init()
    {
        try
        {
            jbInit();        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    /**Component initialization*/
    private void jbInit() throws Exception
    {
        this.setSize(new Dimension(400,300));
        try
        {
            ip = ip + InetAddress.getLocalHost().getHostAddress();
            System.out.println(ip);
            URL base = getCodeBase();            byte[] b = InetAddress.getLocalHost().getAddress();
            ip1 = ip1 + new String(b);
            System.out.println(b.length);
            for(int i = 0; i < b.length; i++)
            {
                System.out.println(b[i] + "aaa");
            }
            System.out.println(ip1);
            InetAddress c_inet = InetAddress.getLocalHost();              ip2 = ip2 + new Long(c_inet.hashCode());
              System.out.println(ip2);
            ip3 = ip3 + getParameter("id");
              System.out.println(ip3);
            ip4 = ip4 + getParameter("ip");
              System.out.println(ip4);        }
        catch(Exception ex)
        {
            System.out.println("aaaaaaaa");
        }    }    public void paint(Graphics g)
    {
        g.drawString("sssssssssssssss", 250, 250);
        g.drawString(ip3, 100, 100);
        g.drawString(ip, 200, 200);
        g.drawString(ip1, 210, 210);
        g.drawString(ip2, 220, 220);
        g.drawString(ip4, 120, 120);
    }    /**Start the applet*/
    public void start()
    {
    }
    /**Stop the applet*/
    public void stop()
    {
    }
    /**Destroy the applet*/
    public void destroy()
    {
    }
    /**Get Applet information*/
    public String getAppletInfo()
    {
        return "Applet Information";
    }
    /**Get parameter info*/
    public String[][] getParameterInfo()
    {
        return null;
    }
    /**Main method*/
    public static void main(String[] args)
    {
        Applet1 applet = new Applet1();
        applet.isStandalone = true;
        JFrame frame = new JFrame();
        //EXIT_ON_CLOSE == 3
        frame.setDefaultCloseOperation(3);
        frame.setTitle("Applet Frame");
        frame.getContentPane().add(applet, BorderLayout.CENTER);
        applet.init();
        applet.start();
        frame.setSize(400,320);
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
        frame.setVisible(true);
    }    //static initializer for setting look & feel
    static
    {
        try
        {
            //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        }
        catch(Exception e)
        {
        }
    }
}

解决方案 »

  1.   

    我也是这么怀疑的,但具体是哪个安全权限?我试过java.net.SocketPermission,没有用。
      

  2.   

    这个我就不知道了,不过你可以试试给你的applet签名。
      

  3.   

    分特!!!!!
    没有联上INTERNET的机器IP地址都是127。0。0。1
    你 PING这个就可以检测你的TCP安装是否正确
      

  4.   

    多谢各位,不好意思,昨天我改策略文件是弄错对象了。添加java.net.SocketPermission的resolve项就可以了。