206.191.48.138 writes:
I am trying to include some JAVA animation in my web page through JAVA applets. I've tried different things and can't get it to work. I can't even get a simple GIF image to appear on screen. I tried emailing several JAVA book authors and they ALL tell me the code looks fine and should work. Well it doesn't!! Here is the code:
import java.awt.Graphics;
import java.applet.Applet;
import java.awt.*;
public class Animation extends Applet {
Image myImg;
public void init() {
myImg = getImage(getCodeBase(), "Lines.GIF");
}
public void Paint(Graphics g) {
g.drawImage(myImg, 0,0, null);
}
}
"Lines.GIF" is my image. It is in the same directory as my class file. I even added a
with the same image and it does appear on my page but the applet image doesn't. Here
is the HTML code:
Any comments or solution will be greatly appreciated. Thank you.
Jon
194.158.187.242 writes:
Sometimes the error is not in the code, but in the GIF. JAVA is quite choosy about GIF's. A GIF that looks great in a browser may not show up in JAVA. On runtime JAVA does give errors for erroneous GIF's. Try another GIF, any will do, from another working sample program. If your coding works with other GIF's, you probably need another GIF editor. Have fun with it.
Henk Jan