@SuppressWarnings("unused")
public void captureMovie()
  {
    boolean done = false;
    BufferedImage image = null;
    long startTime = 0;
    long endTime = 0;
    int timeToSleep = (int) (1000 / framesPerSecond);
    int actualTime = timeToSleep;
    int count = 0;
    Thread current = Thread.currentThread();
    while (current == active)
    {
      try {
        startTime = System.currentTimeMillis();
        image = new Robot().createScreenCapture(region);
        frameSequencer.addFrame(new Picture(image));
        endTime = System.currentTimeMillis();
        if (endTime - startTime < timeToSleep)
            Thread.sleep(timeToSleep-(endTime-startTime));
      } catch (Exception ex) {
        System.out.println("caught exception in StartMovieCapture");
        done = true;
      }
    }
  }