Background image and coloured text

This applet loads an image on the screen and print a text below. The text is animated by toggling a letter in turn between red and black.

The java code looks like this

Start the applet here

Some observations

First variables are declared background, width, height

message is the animated text (it can be changed as a parameter)

The animation is implemented as a thread (my_thread)

The init-function

Image is loaded in the memory as an offscreen image

The internal Class ImageObserver watches the image loading and as soon as the image is fully loaded it calls the ImageUpdate function. The paint function tries to paint the image on the screen, but it can do the job only after it gets the message  (done_loading_image) from the ImageUpdate.

The characters of the parameter are placed in an array. The characters are printed from there one at a time.

When imageUpdate is finnished with following the loading of the image it runs the thread which in turn will start the run function.

The run function used font-metrics to meassure the messages dimensions.

The variable redcharacter will start from 0 and move through all the characters showing which character to turn red in each round.

x shows the starting location of each character in the word. x will be incremented by the width of each character in the char_array.

the delay function delays the drawing of the words by half second.