implements CommandListener {
AlertType[] alertTypes = {
AlertType.ALARM, AlertType.CONFIRMATION, AlertType.ERROR,
AlertType.INFO, AlertType.WARNING
};
ChoiceGroup typesCG;
int[] timeouts = { 2 * SECOND, 4 * SECOND, 8 * SECOND, Alert.FOREVER };
ChoiceGroup timeoutsCG;
ChoiceGroup indicatorCG;
public AlerListener(ChoiceGroup types, ChoiceGroup timeouts,
ChoiceGroup indicator) {
typesCG = types;
timeoutsCG = timeouts;
indicatorCG = indicator;
}
public void commandAction(Command c, Displayable d) {
if (c == CMD_SHOW) {
int typeIndex = typesCG.getSelectedIndex();
Alert alert = new Alert("Alert");
alert.setType(alertTypes[typeIndex]);
int timeoutIndex = timeoutsCG.getSelectedIndex();
alert.setTimeout(timeouts[timeoutIndex]);