Source of DigitalClock2.java


  1: /* 
  2:  * Copyright (c) 1999-2002, Xiaoping Jia.  
  3:  * All Rights Reserved. 
  4:  */
  5: 
  6: import java.awt.Color;
  7: 
  8: /**
  9:  *  This is an ehhanced version of DigitalClock. It takes a parameter: color
 10:  *  It displays the time in the following format:
 11:  *        HH:MM:SS
 12:  */
 13: public class DigitalClock2 extends DigitalClock {
 14: 
 15:   public void init() {
 16:     String param = getParameter("color");
 17: 
 18:     if ("red".equals(param)) {
 19:       color = Color.red;
 20:     } else if ("blue".equals(param)) {
 21:       color = Color.blue;
 22:     } else if ("yelow".equals(param)) {
 23:       color = Color.yellow;
 24:     } else if ("orange".equals(param)) {
 25:       color = Color.orange;
 26:     } else {
 27:       color = Color.green;
 28:     }
 29:   }
 30: 
 31: }