import javax.swing.JPanel;
import java.awt.Graphics;
// Recorre de izquierda a derecha una cadena de texto
public class Letrero extends JPanel implements Runnable
{
Thread Hilo;
String CAD = "Animado";
int x = 10;
public void start( )
{
if (Hilo == null)
{
Hilo = new Thread(this);
Hilo.start( );
}
}
public void run( )
{
// AQUI VA LA ANIMACION
while(x < 300)
{
try { Thread.sleep(500); }
catch(InterruptedException r)
{// CODIGO PARA LA ATENCION A LA INTERRUPCION
}
x += 10;
repaint();
}
}
public void paint(Graphics G)
{
G.clearRect(0, 0, 400, 250);
G.drawString(CAD, x, 10); // (cadena, x, y)
}
}