CODE:
//animated circles
import java.awt.*;
import BreezyGUI.*;
public class animatedcircle extends GBFrame
{
public void paint(Graphics g)
{
int x = 50, y = 50, width = 50, height =
50; // we are using a circle
int i;
for (i = 1; i <= 10; i++)
{
// draw the circle in red
g.setColor(Color.red);
g.drawOval(x, y, height, width);
pause(200);
// draw the circle in white to erase
if (i == 10)
g.setColor(Color.red); // leaves a red
circle when done
else
g.setColor(Color.white);
g.drawOval(x,
y, height, width);
//make adjustments to move the circle
width = (int)
(width*1.25);
height
= (int) (height*1.25);
}
Font ArialB16 = new Font("Arial", Font.BOLD, 16);
g.setColor(Color.red);
g.setFont(ArialB16);
g.drawString("Java Moves!!!", 180, 240);
}
//Main
public static void main (String[] args)
{
Frame frm = new animatedcircle();
frm.setSize (440,440);
frm.setVisible(true);
}
//Method to pause
public static void pause (int time)
{
try
{
Thread.sleep(time);
}
catch(InterruptedException e)
{
}
}
}
|