Bonjour � tous,
Dans mon applet j'ai un MediaTracker qui me permets de
charger
plusieurs images (une cinquantaine... c'est pas trop
?).
Les 6 premi�res images s'affichent bien mais au moment
d'afficher la 7eme
j'ai un magnifique java.lang.OutOfMemoryError <<no stack
trace available>>
qui s'affiche.
Voici ma m�thode run() dans laquelle je charge mes images
avec
tracker.waitForID(id);
id est l'index de l'image dans le MediaTracker
tracker.
public void run()
{
try {
try {
while (change ==
Thread.currentThread()) {
synchronized (this) {
tracker.waitForID(id);
if(id == images.size()) {
id = 0;
}
repaint();
Thread.sleep(3000);
}
}
}
catch (InterruptedException e) {
stop();
}
}
synchronized (this) {
tracker.waitForID(id);
if(id == images.size()) {
id = 0;
}
repaint();
Thread.sleep(3000);
}
}
}
catch (InterruptedException e) {
stop();
}
}
Et voici ma m�thode paint() dans laquelle j'affiche mes
images:
public void paint(Graphics g)
{
if (img == null) {
return;
}
if (tracker.statusID(id, false) == MediaTracker.COMPLETE) {
g.drawImage(img, 25, 100, 400, 250, this);
if (img == null) {
return;
}
if (tracker.statusID(id, false) == MediaTracker.COMPLETE) {
g.drawImage(img, 25, 100, 400, 250, this);
id++;
}
}
}
}
Est-ce que quelqu'un peu m'aider ?
Merci d'avance,
Jean Michel Flambard
