//This is the program from today's lab with the plane landing
// This is a good example of anaimation and using a for loop and if
// statements to control the plane.
// The if statements are used to make the plane level off at bottom of the
frame
// Study this and all of you will learn a lot
import java.awt.*;
import java.net.*;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
public class Application1
{
public Application1()
{
int b;
Frame df = new Frame("application frame");
df.setSize(800,500);
df.show();
Graphics g =
df.getGraphics();
Thread th=new Thread();
g.setColor(Color.blue);
g.setXORMode(Color.white);
for(int a=1;a<800;a++)
// start of loop
{
if (a<479) b=a;
else b=479;
g.fillOval(a,b,40,4);
try
{
th.sleep(25);
}
catch(Exception e)
{
}
if (a<479) g.fillOval(a,b,40,4);
else
{
b=479;
g.fillOval(a,b,40,4);
}
}
// end of loop
}
public static void main(String[] args)
{
Application1 app = new Application1();
System.exit(0);
}
}
|