Objectives:
In the main program, add an Animator object and start the
animation as discussed in class. Oops! Do you see flickering? Add double buffering to fix. |
Add an elapsed time clock in the upper right hand corner of the
canvas. You can use the System.currentTimeMillis() function to get the current time. Using the start time and a current time, you can easily compute the number of elapsed seconds. Using modulo arithmetic, you can convert elapsed seconds to elapsed hours, minutes, and seconds for your display. Another helpful class is the Time class. The Time constructor will take a string of hours:minutes:seconds and automatically add leading zeros where necessary. Then you can simply use your display lists to render that string (obtained with the toString method). |
Add a menu choice to allow resetting the elapsed time to 0. |