Reload no applet

0 respostas
jason_bourne

Pessoal,

Estou tentando dar um reload de segundo em segundo nesse applet, mas não manjo como se faz, alguem pode me ajudar?

import java.awt.*;
import java.applet.*;
 
public class animacao extends Applet{

void sleep(int iTime){
     try { Thread.sleep( iTime ); }
     catch (InterruptedException e) { }
}

public void run() {
    int conta = 0;
    while (conta < 100) {
    repaint();
    sleep( 100 );
    conta++;
    }

}

public void update(Graphics g)
{
     paint(g);
}

public void paint( Graphics g ) {
 
int x=0,y=0;//x = coluna, y = linha
 
g.setColor( Color.black ); 
                
for(x=0;x<10;x++){
  for(y=0;y<10;y++){
    if(aleatorio(255) % 2 == 0)
     g.fillRect( x*19, y*19, 19, 19 );
    else
     g.draw3DRect( x*19, y*19, 19, 19, true );
  }
}
 
}
 
	
private int aleatorio( int rango ) {
 double retornoMath;
 retornoMath = Math.random();
 return( (int)( retornoMath * rango ) );
}  	

}

só que ele não faz o reload

Criado 8 de junho de 2005
Respostas 0
Participantes 1