Java阻止我运行本地java applet

时间:2015-01-05 00:42:54

标签: java security applet

我有一个简单的小程序,我想在本地运行,但java阻止它。

小程序代码是这样的:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class FollowMe extends JApplet
{
private int xCoord = 100, yCoord = 100;

/**
 * init method
 */

public void init()
{
    setBackground(Color.WHITE);
    addMouseMotionListener(new MyMouseMotionListener());
}

/**
 * paint method
 */

public void paint(Graphics g)
{
    // Call the base class paint method.
    super.paint(g);

    // Draw the string at the current mouse location.
    g.drawString("Hello", xCoord, yCoord);
}

/**
 * Private inner class that handles mouse
 * motion events.
 */

private class MyMouseMotionListener implements MouseMotionListener
{
    /**
     * mouseMoved method
     */

    public void mouseMoved(MouseEvent e)
    {
        // Get the mouse pointer's X and Y coordinates.
        xCoord = e.getX();
        yCoord = e.getY();

        // Force the paint method to execute.
        repaint();
    }

    /**
     * Unused mouseDragged method
     */

    public void mouseDragged(MouseEvent e)
    {
    }
}
}

当然,我在HTML文件中引用了类文件。 我已经转到我的JAVA安全设置并添加了以下异常:

“file:/// D:/Downloads/AppletsExamples%281%29/01%20-%20FollowMe%20Applet/FollowMe.html”

你可以看到我在firefox中打开以访问我的Html文件的路径。 但是,JAVA仍会阻止applet。这变得非常令人沮丧,我在其他地方找不到任何帮助。

0 个答案:

没有答案