Tuesday, 20 September 2011

Graphics Using ball


import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JFrame;
public class hellokid extends Frame{
int x=50;
int y=50;
int dx=1;
int dy=1;
public hellokid() {
setSize(800,600);
setVisible(true);
}@Override
public void paint (Graphics g) {
g.setColor(Color.black);
g.drawOval(x,y,200,200);
g.fillOval(x,y, 200,200);
super.paint(g);
x=x+dx;
y=y+dy;
if(x==500 && y==500){
x=50;y=50;
dx=1;
dy=1;

repaint();
}


repaint();
for(int a=1;a<20000000;a++){}
}
public static void main (String arg[])
{
hellokid w=new hellokid();
}
}

No comments:

Post a Comment