/** Creates a new ProgressIndicatorScreen object */
  public ProgressIndicatorScreen() {
    setTitle("Progress Indicator Screen");

    // Initialize progress indicator
    final ProgressIndicatorView view = new ProgressIndicatorView(0);
    _model = new ProgressIndicatorModel(0, 100, 0);
    final ProgressIndicatorController controller = new ProgressIndicatorController();
    _model.setController(controller);
    _model.addListener(new DemoProgressIndicatorListener());
    view.setModel(_model);
    view.setController(controller);
    controller.setModel(_model);
    controller.setView(view);
    view.setLabel("Progress");
    view.createProgressBar(Field.FIELD_HCENTER);

    // Initialize buttons
    _processButton =
        new ButtonField("Process data", ButtonField.NEVER_DIRTY | ButtonField.CONSUME_CLICK);
    _processButton.setChangeListener(this);
    _cancelButton = new ButtonField("Cancel", ButtonField.NEVER_DIRTY | ButtonField.CONSUME_CLICK);
    _cancelButton.setChangeListener(this);
    _resumeButton = new ButtonField("Resume", ButtonField.NEVER_DIRTY | ButtonField.CONSUME_CLICK);
    _resumeButton.setChangeListener(this);

    // Add buttons to manager
    final HorizontalFieldManager hfm = new HorizontalFieldManager(Field.FIELD_HCENTER);
    hfm.add(_processButton);
    hfm.add(_cancelButton);
    hfm.add(_resumeButton);

    add(hfm);
    add(new SeparatorField());
    add(view);
  }
  /** @see FieldChangeListener#fieldChanged(Field, int) */
  public void fieldChanged(final Field field, final int context) {
    if (field == _processButton) {
      if (_progressThread != null) {
        // Kill the currently running progress thread
        _progressThread.stopThread();
      }

      // Start a new progress thread
      _progressThread = new ProgressThread();
      _progressThread.start();
    } else if (field == _cancelButton) {
      _model.cancel();
    } else if (field == _resumeButton) {
      _model.resume();
    }
  }