/*--------------------------------------------------
* Animation.java
*
* Demonstrate simple animation using
* a Timer and TimerTask
*
* Example from the book:     Core J2ME Technology
* Copyright John W. Muchow   http://www.CoreJ2ME.com
* You are free to use/modify this source code.
*-------------------------------------------------*/
import java.util.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Animation extends MIDlet
{
  private Display  display;       // The display
  private AnimationCanvas canvas; // Canvas
  private Timer tm;               // Timer
  private AnimateTimerTask tt;    // Task

  public Animation()
  {
    display = Display.getDisplay(this);
    canvas  = new AnimationCanvas(this);

    // Create task that fires off every 1/10 second
    tm = new Timer();
    tt = new AnimateTimerTask(canvas);
    tm.schedule(tt, 0, 100);
  }

  protected void startApp()
  {
    display.setCurrent(canvas);
  }

  protected void pauseApp()
  { }

  protected void destroyApp(boolean unconditional)
  { }

  public void exitMIDlet()
  {
    destroyApp(true);
    notifyDestroyed();
  }
}
