[fontfamily=courier,fontsize=\relsize{-3},frame=single] System.out.println("He pulsado el botón Ok"); javax.microedition.lcdui.Display.getDisplay(this).setCurrent(miCanvas);sustituyéndolas por el siguiente trozo de código para que sólo se muestre el el canvas cuando tenemos seleccionado la opción Jugar en el ChoiceGroup:
[fontfamily=courier,fontsize=\relsize{-3},frame=single] if(choiceGroup1.getSelectedIndex()==0){ System.out.println("Ha seleccionado Jugar"); javax.microedition.lcdui.Display.getDisplay(this).setCurrent(miCanvas); } else if(choiceGroup1.getSelectedIndex()==1){ System.out.println("Ha seleccionado Opciones"); } else if(choiceGroup1.getSelectedIndex()==2){ System.out.println("Ha seleccionado Ver records"); }
Command
.incluido en el canvas:
[fontfamily=courier,fontsize=\relsize{-3},frame=single] /** * constructor */ public MiCanvas(TetrisMidlet t) { try { // Set up this canvas to listen to command events setCommandListener(this); // Add the Exit command exitCommand = new Command("Exit", Command.EXIT, 1); addCommand(exitCommand); tetrisMidlet = t; } catch(Exception e) { e.printStackTrace(); } }
[fontfamily=courier,fontsize=\relsize{-3},frame=single] /** * Called when action should be handled */ public void commandAction(Command command, Displayable displayable) { if (command == exitCommand) { javax.microedition.lcdui.Display.getDisplay( tetrisMidlet).setCurrent(tetrisMidlet.helloForm); } }