ZDraw

To use this applet, you will need to grab the appropriate Java Runtime Enviroment from Sun.

ZDraw is a fairly basic drawing applet used to demonstrate the concept of persistence in a drawing applet. What do I mean by persistence? Well, take most of the "demo" drawing applets available on the 'net. If you put the applet into the background, resize it, or partially/fully cover it with another window, then the "hidden" portion of the applet loses any drawings that were made.

A simple (and rudimentary) solution to this can be easily implemented using a Vector and creating a new object class LineObject within which we can store the start and end points of each line, together with its colour. Then, when we can override public void paint( Graphics g ) and insert some code that iterates through each element of the vector, repainting each line segment. This way, everytime the applet redraws itself, all of the lines will be repainted, and thus will not be lost!

The source code is fairly well documented, but if you have any questions, please Contact me!

Use the scrollbars to change the "pen" colour. From left-to-right, they control the red, green and blue colour components respectively.

Valid CSS!

Valid HTML 4.01!