import java.awt.*;
import javax.swing.*;

public class PruebaGrafica2{
    public static void main(String args[]){
        new PruebaGrafica2();
    }
    PruebaGrafica2(){
        JFrame ventana=new JFrame("Probando");
        ventana.setSize(600,500);
        ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Pizarrin p=new Pizarrin();
        ventana.add(p);
        ventana.setVisible(true);
    }
}

class Pizarrin extends Canvas{
    Pelota p;
    Pizarrin(){
        p=new Pelota(this);
        p.start();
    }
    public void paint(Graphics g){
        g.drawOval(p.x,p.y,30,30);
    }
}

class Pelota extends Thread{
    int x;
    int y;
    Canvas c;
    Pelota(Canvas a){
        c=a;
    }
        
    public void run(){
        while(x<600){
            x=x+10;
            y=y+10;
            try{Thread.sleep(1000);}catch(Exception e){}
            c.repaint();
        }
    }
}
    