/*
 * Copyright (c) 2004 David Flanagan.  All rights reserved.
 * This code is from the book Java Examples in a Nutshell, 3nd Edition.
 * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.
 * You may study, use, and modify it for any non-commercial purpose,
 * including teaching and use in open-source projects.
 * You may distribute it non-commercially as long as you retain this notice.
 * For a commercial use license, or to purchase the book, 
 * please visit http://www.davidflanagan.com/javaexamples3.
 */
import java.applet.AudioClip;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.NumberFormat;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.Timer;
/**
 * An applet that counts down from a specified time. When it reaches 00:00, it
 * optionally plays a sound and optionally moves the browser to a new page.
 * Place the mouse over the applet to pause the count; move it off to resume.
 * This class demonstrates most applet methods and features.
 */
public class Countdown extends JApplet implements ActionListener, MouseListener {
  long remaining; // How many milliseconds remain in the countdown.
  long lastUpdate; // When count was last updated
  JLabel label; // Displays the count
  Timer timer; // Updates the count every second
  NumberFormat format; // Format minutes:seconds with leading zeros
  Image image; // Image to display along with the time
  AudioClip sound; // Sound to play when we reach 00:00
  // Called when the applet is first loaded
  public void init() {
    // Figure out how long to count for by reading the "minutes" parameter
    // defined in a  tag inside the