import java.awt.*;
import javax.swing.*;
import java.awt.event.*;


  public class Anim2 extends JApplet implements ActionListener {

                                                                                   Display disegno;
   Timer timer;
   int x,y,r;
   Image o;
   Graphics og;
   
   public void init() {

     disegno = new Display();
     setContentPane(disegno);
     x = 0; y=200; r=50;
     }

   public void start() {
    if (timer == null) {
        timer = new Timer(100,this);
        timer.start();
    }
   }

  public void stop() {
     if (timer != null) {
       timer.stop();
     }
   }

   public void actionPerformed(ActionEvent e) {
      x = x + 1;
      if(x>disegno.getSize().width)x = 0;
        disegno.repaint();
 }
    class Display extends JPanel{


    public void  paintComponent(Graphics g) {
      super.paintComponent(g);
      g.setColor(Color.red);
      g.fillOval(x,y,2*r,2*r);


   }
   }
}
