I've been surfing the web for weeks now and can't find anyone who has experienced this strange behaviour when loading and displaying pictures on a canvas. I load an array of images from the disk drive in the Applet init method and then proceed to display them using my own graphic context and .drawImage in my UpdateCanvas method. The UpdateCanvas method calls repaint() and I override the Update method. The weird thing is that some images are displayed while others are not. I've tried using Mediatracker code thinking that the images had simply not fully loaded, and that's why they were not displayed but I had no luck with this. I introduced a delay of a second, again thinking that the compiler could not load everything in time, and no luck. I've posted the revalent code down here, the UpdateCanvas method is seperate from everything else cause I needed a method that I can allows me to update new display pictures when the user presses certain keys. Any help would be really appreciated, thanks...
Graphics gContext;
private Image TestArray = new private Image[80];
private Image Background = getImage(getDocumentBase(), "Background.gif");
public void init() {
for (i=0;i<80;i++) {
TestArray = getImage(getDocumentBase(), "Test" + i + ".gif");
}
Buffer = createImage(800, 800);
gContext = Buffer.getGraphics();
gContext.setColor(Color.white);
}
public void UpdateCanvas() {
gContext.drawImage(Background, 0, 0, this);
for(int i=0;i<80;i++) {
gContext.drawImage(TestArray, x, 100, this);
x=x+10;
}
repaint();
}
public void paint(Graphics g) {
g.drawImage(Buffer, 0, 0, this);
}
public void update(Graphics g) {
paint(g);
}