import java.awt.*;
import javax.swing.*;
public class Animation extends JApplet {
int x = 10;
int y = 10;
Drawing d;
public void init(){
setSize(500, 500);
d = new Drawing();
Container content = getContentPane();
content.add(d, BorderLayout.CENTER);
content.setVisible(true);
}
public void start(){
go();
}
public void go(){
for (int i = 0; i < 330; i++){
x++;
y++;
d.repaint();
try{
Thread.sleep(20);
} catch (Exception ex){}
}
}
public class Drawing extends JPanel {
public void paintComponent(Graphics g) {
super.paint(g);
Graphics2D g2 = (Graphics2D) g;
this.setBackground(Color.BLACK);
g.setColor(Color.ORANGE);
g.fillOval(x, y, 30, 30);
}
}
}