import javax.microedition.lcdui.;
import javax.microedition.midlet.;
public class ExemploListAndAlert extends MIDlet implements CommandListener {
private Display tela;
private TextBox t1;
private Command sair, prox, prox1;
private Alert alarme, confirmacao, erro, info, aviso;
private List menu, exclusiva, multipla;
public ExemploListAndAlert() {
String[] menuElementos = { "Alarme", "Confirmação", "Erro", "Info", "Aviso", "Exclusiva", "Multipla" };
String[] exclusivaElementos = { "Opcao1", "Opcao2", "Opcao3", "Opcao4", "Opcao5", "Opcao6" };
String[] multiplaElementos = { "Opcao1", "Opcao2", "Opcao3", "Opcao4", "Opcao5", "Opcao6"};
this.alarme = new Alert("Alarme", "Alerta de Alarme", null, AlertType.ALARM);
this.alarme.setTimeout(5000);
this.confirmacao = new Alert("Confirmacao", "Alerta de confirmacao", null, AlertType.CONFIRMATION);
this.confirmacao.setTimeout(4000);
this.erro = new Alert("Erro", "Alerta de erro", null, AlertType.ERROR);
this.erro.setTimeout(Alert.FOREVER);
this.info = new Alert("Info", "Alerta de Info", null, AlertType.INFO);
this.aviso = new Alert("Aviso", "Alerta de aviso", null, AlertType.WARNING);
this.prox = new Command("Prox", Command.SCREEN, 1);
this.prox1 = new Command("Prox", Command.SCREEN, 1);
this.sair = new Command("Sair", Command.EXIT, 0);
this.t1.addCommand(this.sair);
this.t1.setCommandListener(this);
this.exclusiva = new List("Exclusiva", Choice.EXCLUSIVE, exclusivaElementos, null);
this.exclusiva.addCommand(this.sair);
this.exclusiva.addCommand(this.prox);
this.multipla = new List("Multipla", Choice.MULTIPLE, multiplaElementos, null);
this.multipla.addCommand(this.sair);
this.multipla.addCommand(this.prox1);
this.menu = new List("Menu", Choice.IMPLICIT, menuElementos, null);
this.menu.addCommand(this.sair);
this.menu.setCommandListener(this);
}//fim do ExemploListAndAlert()
public void startApp() {
this.tela = Display.getDisplay(this);
this.tela.setCurrent(this.menu);
}//fim do startApp
public void destroyApp(boolean i) {}//fim do destroyApp
public void pauseApp() {}//fim do pauseApp
public void commandAction(Command c, Displayable d) {
String opcao = "";
if (c == this.sair) {
this.destroyApp(true);
this.notifyDestroyed();
}//fim do if
if (c == this.prox) {
opcao = this.exclusiva.getString(this.exclusiva.getSelectedIndex());
this.t1.setString(opcao);
this.tela.setCurrent(this.t1);
}//fim do if
if (c == this.prox1) {
for (int count=0; count<6; count++) {
if (this.multipla.isSelected(count)) {
opcao = opcao+this.multipla.getString(count)+"\n";
}//fim do if
}//fim do for
this.t1.setString(opcao);
this.tela.setCurrent(this.t1);
}//fim do if
if ((c == List.SELECT_COMMAND) && (d == this.menu)) {
int selecionado = this.menu.getSelectedIndex();
switch (selecionado) {
case 0:
this.tela.setCurrent(this.alarme);
break;
case 1:
this.tela.setCurrent(this.confirmacao);
break;
case 2:
this.tela.setCurrent(this.erro);
break;
case 3:
this.tela.setCurrent(this.info);
break;
case 4:
this.tela.setCurrent(this.aviso);
break;
case 5:
this.exclusiva.setCommandListener(this);
this.tela.setCurrent(this.exclusiva);
break;
case 6:
this.multipla.setCommandListener(this);
this.tela.setCurrent(this.multipla);
break;
}//fim do switch
}//fim do if
}//fim do commandAction
}//fim da classe ExemploListAndAlert