Ask Questions?

View Latest Questions

Advertisement


 
 

Extend Text Clock
Posted on: July 22, 2006 at 12:00 AM
Here are several possible extensions to Example - Text Clock 2.

Java: Example - Extend Text Clock

Here are several possible extensions to Example - Text Clock 2.
  1. Minor changes. The time should be centered in the field. This can be done by calling the setHorizontalAlignment(JTextField.CENTER). Another similar change would be to make the text field uneditable by the user. A call to setEditable(false) would accomplish this. Where should these calls go?
  2. Leading zeros. The convention for showing digital time is to use two digits with leading zeros. For example, 5 minutes and 3 seconds after 8 is usually shown as "08:05:03", not "8:5:3". This requires the addition of some tests to add an extra "0" character when numbers are less than 10.
  3. AM/PM. The clock could be changed to use the 12-hour system, and show an additional "AM" or "PM". This option could be built-in, or it could be settable.
  4. Alarm or Timer. A more ambitious project is to make an alarm clock or countdown timer. This requires the addition of controls to turn this feature on and off. Do you want a Snooze button?

    Design the user interface first. It would be easiest to always show the alarm time as a smaller display, with a check box or toggle button to turn it on and off.

Copyleft 2003 Fred Swartz MIT License, Last update: 2003-10-29
Advertisement


DMCA.com