Importing images

Hi,

I'm trying to import an image into my applet. But it doesn't appear. What am I doing wrong?

import java.awt.*;

import java.applet.*;

public class ImageDemo extends java.applet.Applet {

private Image image;

public void paint(Graphics gr)

{

gr.drawImage(image, 10,10, this);

}

public void init() {

super.init();

image = getImage(getCodeBase(), "testimage.gif");

resize(620,220);

}

}

[484 byte] By [Mexela] at [2007-11-27 11:17:07]
# 1

I tryed your code and it works perfect. (I made a gif in windows paint)

Make sure you really have that image in the same directory as your Applet. Maybe someting is wrong with your picture - try another image.

Ja_Lava_Javaa at 2007-7-29 14:23:03 > top of Java-index,Java Essentials,New To Java...
# 2

i had so much problems with this before...

Java might be outdated, computer is capricious(that was mine worked on every other comp except mine...), picture is not int he right folder, picture is bad, picture size is wrong? the buffer speed is making it seem like its not there while in reality you see the white part of the refresh.

try it on another computer, and make sure you have the picture in the right place(if you are using netbeans, it should be in the project folder and does not need to be anywhere else.)

PlasmaLinka at 2007-7-29 14:23:03 > top of Java-index,Java Essentials,New To Java...
# 3

OK, nice to hear that someone else have had this problem too. Because it has just drivin me mad. (the pic is in correct folder, has correct format. I've been over this more than once =))

I will try it on another computer as you suggests, but it still bother me that I can't figure out what's wrong.

Mexela at 2007-7-29 14:23:03 > top of Java-index,Java Essentials,New To Java...