<:> Moving images



The 'drawImage' methods of the Graphics class let you display images from files.

The Thread class can be used to create a process which runs `in the background' allowing the user to interact with it using the mouse.

The easiest way to set up this kind of animation is to make the JPanel class implement the 'Runnable' interface.

The background behaviour can then be defined using a 'run' method placed in the class definition.

The background process can be launched using 'new Thread(appletPanel).start()'.

This approach is illustrated in the MovingImages applet which has the CS logo moving down and across the screen.

Clicking with the mouse resets the position of the logo.

Note also the use of the getImage method to fetch the image file. (This has to be in the same folder as the applet.)