last revised July 13, 2006 (except for formatting)
Copyright © 2006 by Allan M. Stavely. All rights reserved.
Table of Contents
This document presents code to implement a variable-speed digital clock that will run in a window on a computer's display screen. The clock will have controls to do the following:
set the clock to a given time
set the speed of the clock; i.e., the rate at which the seconds "tick" relative to the normal rate
make the clock pause or start "ticking" again
turn off or on the display of seconds, because at high speeds the rapidly changing display of seconds may be annoying to the observer
change between 12-hour am/pm and 24-hour display of the time
The programming language is Java. I chose the above set of features, not because of any particular need, but to allow me to learn about Java and its libraries, particularly the facilities for threading, atomic variables, and graphical user interfaces. For all practical purposes, what you see here is just a programming exercise.
I will not attempt to explain all of the features of Java and its libraries that I use; readers who want all the details should consult the on-line Java reference material or some other reference material on Java.
Disclaimer: I am not an experienced Java programmer. This is my first Java program. Much of the code here was written by imitating examples in [On to Java] by Patrick Henry Winston and Sundar Narasimhan (Addison Wesley, 2001). Of course, I take responsibility for any flaws, including bugs and clumsy use of the Java language.