Sample Java Clock


Local

GMT

PST

Note: If this isn't working, it is probably because you need to rename Clock.cla to Clock.class, and rename Clock.jav to Clock.java. This is because the compression utility used to "zip" up the tool kit doesn't handle long names.

This applet was originally developed as an exercise to learn several Java packages. To make it more efficient, you could replace the code that calculates the graphical coordinates with a table. However, one of the purposes in developing this was to learn the Java math packages.

This clock accepts the following parameters to be passed in:

ParameterDescription
facecolor This is the color of the clock's face. If this parameter is not specified, the default "white" will be used. Acceptable colors are: blue, cyan, green, magenta, orange, pink, red, white, yellow, black, darkGray/darkGrey, gray/grey, lightGray/lightGray,
clockcolor This is the color of the minute and hour hands, as well as the clock's outline. The default is black. See "facecolor" for a list of supported colors.
fontcolor This is the color of font used to write "AM" or "PM" on the clock face. The default is gray. See "facecolor" for a list of supported colors.
background This is the color to be used for the background. The round clock is drawn on a rectangle drawing area, leaving the corners exposed. This is the color that will appear between the clock and the edge of the drawing area. The default is white. See "facecolor" for a list of supported colors.
sechand Specifies whether the second hand is to be displayed or not. You may specify true (the second hand is displayed) or false. The default is "true".
tickmarks Specifies whether the 5 minute tick marks are to be drawn or not. You may specify true (they are displayed) or false. The default is "false".
lclick Specifies the URL that will be retrieved if the the left mouse button is clicked while the mouse is in the clock area. It must be valid URL syntax.
gmtoffset This is the offset to GMT and is used similar to the Date object's getTimezoneOffset method. It is the count of timezones from GMT. EST is 5, PST is 8, etc. It does not take into account Daylight Savings Time, so you will need to modify your HTML document to add or subtract from this number if specified. If you don't specify this parameter, the client's time is used.