Very easy question about IMAGE!
Posted on 2001-06-11
Look at this:
/*<applet code = "Game15" width = 242 height = 265> </applet>*/
public class Game15 extends Applet
public void init()
public void paint(Graphics g)
URL baseURL = getCodeBase();
ImageBG = getImage(baseURL, "images/board.jpg");
The idea is to create an applet 240x240 with red background, image on the top and a small LINE at the bottom.
I compiled it in Java 1.0.2 and tried this sample in the different browsers and got different results!!!!!
1. In appletviewer I always get what I want without any problems!!!!!!!!!!!!!!!!
2. In IE 5.?0 it draws everything but SOMETIMES it does not redraw an image if I use repaint().
3. In IE 4.?0 it doesn't redraw an image almost always.
4. In Netscape 4.08 this sample made only red background without LINE and IMAGE. But I was able to play some JAVA-games with graphics from WebSites.
In all cases Browsers doesn't show any errors!
Where is the problem in my code? What code should I use to display an images in both type of Browsers?
Thank you in advance!