done();
}
private Alert _alert;
private int _counter;
private boolean _done;
private Gauge _gauge;
}
// An alert test that displays a continuously
// running gauge before automatically timing out.
public class BusyAlert extends AlertRunner
{
public BusyAlert(String title)
{
super(title);
}
public Alert doAlert()
{
_gauge = new Gauge(null, false, Gauge.INDEFINITE,
Gauge.CONTINUOUS_RUNNING);
_alert = new Alert(getTitle());
_alert.setString("Runs for 5 seconds and "
+ "times out automatically");
_alert.setIndicator(_gauge);
_alert.setTimeout(FIVE_SECONDS);
showAlert(_alert);
return _alert;
}
private Alert _alert;
private Gauge _gauge;
}
// Standard MIDlet code. Displays a list of
// available alert tests and runs the test once
// it's been chosen.
private Display display;
public static final Command exitCommand = new Command("Exit", Command.EXIT,
1);
public AlertTest()
{
}
public void commandAction(Command c, Displayable d)
{
if (c == exitCommand)
{
exitMIDlet();
} else if (c == List.SELECT_COMMAND)
{
int index = _alertList.getSelectedIndex();
_alertRunners[index].doAlert();
}
}
protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException
{
exitMIDlet();
}
public void exitMIDlet()
{
notifyDestroyed();
}
public Display getDisplay()
{
return display;
}
protected void initMIDlet()
{
// The list of alert tests....
_alertRunners = new AlertRunner[] { new TimedAlert("Timed alert"),
new ModalAlert("Modal alert"),
new ProgressAlert("Progress alert"),
new BusyAlert("Busy alert") };