Welcome to Computer Programming




To do animation or anything that requires delay, in the builder, just drag over animation. It adds two things to your code (so you could do it manually).

In initialize, it adds :




It also adds another method - update which gets called automatically every 50 milliseconds.Update gets the temporary layer and when you are done, it will automatically call drawScreen putting up that temporary layer.

			  //the method below will get called every frame.
              //its argument g is the temporary graphics layer
              public void update(Graphics g)
              //put your code for what should happen each animation





In a class called HWJ10_Text, have some fun text (use g.drawString("text",x,y); Starter

  1. move back and forth on the screen.
  2. Add code so that every 40 times it moves the color changes between green and red.
  3. Add code so that when they press 1-3 the animation changes speed. (either change global variable speed, or change the delay - which already is a global variable)
  4. Add code to stop and start the animation via a press of the space bar.



  1. Make the text get bigger and smaller link
  2. Have it so the text bounce around the screen like a ball. Have a it start in a random location and move in a random direction.

You can update the amount of delay (frame rate) by saying:


You can stop animation by saying:


You can start animation by saying: