hi,
I’m writing a simple applet (JApplet actualy) that needs to display images but I’m finding it very difficult.
My code is as follows:
import java.awt.*;
import javax.swing.*;
import java.applet.*;
import javax.imageio.*;
import java.io.*;
/**
*
* @author Nick
*/
public class TestJApplet extends JApplet {
/** Creates a new instance of TestJApplet */
public TestJApplet() {
}
public void init()
{
}
public void paint(Graphics g)
{
Image image = null;
try
{
InputStream is = new BufferedInputStream(new FileInputStream("a.gif"));
image = ImageIO.read(is);
}
catch(Exception e)
{
System.out.println("Exception : " + e);
}
g.drawImage(image, 100,100,this);
g.drawRect(30,30,30,30);
}
}
and get the exception :
java.security.AccessControlException: access denied (java.io.FilePermission a.gif read)
I’ve also tried:
File file = new File("a.gif");
image = ImageIO.read(file);
and
image = getImage(getDocumentBase(), "a.gif");
and get the same access denied message.
Is there a simple way to get an image to load in an Applet (or JApplet)
Thanks in advance 