MIDlet+Form

0 respostas
A

Alguem pode ajuda-me:
fiz um projeto com midlet com somente os metodos basicos e os forms com a implementações, porem,
quando o form chama outro form nao consigo retorna mesmo o camando com BACK.

public class InventarioMIDlet extends MIDlet {

private static InventarioMIDlet instance;	

private Form formMenu;
public InventarioMIDlet() {
	instance = this;
	// cria o formulario 
	formMenu = new MenuInventario("Menu Principal");		
	
}

protected void destroyApp(boolean arg0) {
	// TODO Auto-generated method stub

}

protected void pauseApp() {

}

protected void startApp()  {
	showMainScreen();
}

public void showMainScreen() {
    showDisplayable(formMenu);	
	
}
public static void showDisplayable(Displayable d) {
	Display.getDisplay(instance).setCurrent(d);	
	
}

public static void exit() {
	instance.destroyApp(true);
	instance.notifyDestroyed();
}

}

public class MenuInventario extends Form implements CommandListener{

private Command cmdPalm;

private Command cmdParametro;

private Command cmdProduto;

private Command cmdMovimento;

private Command cmdSair;

private Form formPalm;

private Form formParametro;

private Form formProduto;

private Form formMovimento;
public MenuInventario(String title) {
		super(title);
		cmdSair = new Command("Sair",Command.EXIT,0);
		cmdPalm = new Command("Palm", Command.SCREEN, 1);
		cmdParametro = new Command("Parametro", Command.SCREEN, 2);
		cmdProduto = new Command("Produto", Command.SCREEN, 3);
		cmdMovimento = new Command("Movimento", Command.SCREEN, 4);
		formPalm = new FormPalm("Cadastro de Palm");		
		
		this.addCommand(cmdPalm);
		this.addCommand(cmdParametro);
		this.addCommand(cmdProduto);
		this.addCommand(cmdMovimento);
		this.addCommand(cmdSair);
		this.setCommandListener(this);
		
 }	

	public void commandAction(Command c, Displayable d) {
		if (c == cmdSair){
			if (d == this) {
		        InventarioMIDlet .exit();
			} else {
				InventarioMIDlet .showDisplayable(this);
			}
	     } else if (c == cmdPalm){
	    	 InventarioMIDlet .showDisplayable(formPalm);
		 } else if (c == cmdParametro) {
			 InventarioMIDlet .showDisplayable(formParametro);
		 } else if (c == cmdProduto) {
			 InventarioMIDlet .showDisplayable(formProduto);
		 } else if (c == cmdMovimento) {
			 InventarioMIDlet .showDisplayable(formMovimento);
		 }
 		}// funcao

}

public class FormPalm extends Form implements CommandListener, ItemCommandListener, ItemStateListener {

private Alert alerta;

private Spacer tstSpace;

private TextField codpal, emp, fil;

private Command cmdincluir, cmdexcluir, cmdalterar, cmdlistar, cmdSair;


public void commandAction(Command c, Displayable d) {
	if (c == cmdSair) {
 		try{
    		rs.closeRecordStore();
 		}
 		catch (Exception exc){
			System.out.print("Erro fechando o RecordStore: "+exc.toString());
  		    }
		parent.showMainScreen();
	}else if (c == cmdincluir) {
 		if (gravacaoOK == false){
    		System.out.print("Registro vazio não será salvo" + "Tente novamente");
	    }else {
   		    adicionarRegistro();
	    }
	}else if (c == cmdexcluir) {
    	apagarRegistros();
    }else if (c == cmdlistar) {
	    ListPalm = new ListarPalm("Lista de Palm", ChoiceGroup.MULTIPLE);
	    parent.showDisplayable(ListPalm);
    }
}// funcao
Criado 10 de novembro de 2008
Respostas 0
Participantes 1