no puedo implementar CommandListener desde otro formulario que no sea el principal
NO puedo implementar commandListener desde un formulario que no sea el principal
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
*
* @author Administrador
* @version
*/
public class Form_Preguntas extends MIDlet implements CommandListener {
private Command exitCommand;
private Display display;
private Form screen;
public TextField nombre;
static public String nombre2;
public Form_Preguntas()
{
String[] opciones = {"Chichina", "Chichino" , "Ni帽o" , "Peri" };
display = display.getDisplay(this);
exitCommand = new Command("Salir", Command.EXIT,2);
screen = new Form("PREGUNTAS IMPORTANTES");
StringItem Adivina = new StringItem("","Adivino quien Eres");
nombre = new TextField("Nombre","",30,TextField.ANY);
ChoiceGroup estado = new ChoiceGroup("Opciones",List.EXCLUSIVE,opciones,null);
screen.append(Adivina);
screen.append(nombre);
screen.append(estado);
screen.addCommand(exitCommand);
screen.setCommandListener(this);
// Alert alerta = new Alert ("Error","El dato no es v谩lido", null, AlertType.ERROR);
}
public void startApp() {
display.setCurrent(screen);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c,Displayable s){
if( c == exitCommand) {
// getString(nombre);
nombre2 = nombre.getString();
System.out.println(".:: CHichino ::."+nombre2);
System.out.println("ChiiiiiiiiiiichiiiiiiiiiiiiiiiiiNOOOOOOO");
pantalla tuino = new pantalla(nombre2);
display.setCurrent(tuino.Hola);
/*;
destroyApp(false);
notifyDestroyed();*/
}
}
}
este es el Otro formulario que no funciona COMMANDLISTENER
_______________________________________
import javax.microedition.lcdui.*;
public class pantalla implements CommandListener{
/** Creates a new instance of pantalla */
private Command exitCommand;
public Form Hola;
private Display display;
public pantalla() {
}
// display = display.getDisplay(this);
public pantalla(String A) {
Hola = new Form("PREGUNTAS IMPORTANTES");
if(A.equals("chichina"))
{
StringItem Adivina = new StringItem("","Adivino quien Eres :" + A);
Hola.append(Adivina);
}
StringItem Adivina2 = new StringItem("","ESTO es Una Prueba");
Hola.append(Adivina2);
Hola.addCommand(exitCommand);
Hola.setCommandListener(this);
}
public void commandAction(Command c,Displayable s){
if( c == exitCommand) {
System.out.println(".:: CHichino ::.");
// destroyApp(false);
// notifyDestroyed();
}
}
}
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
*
* @author Administrador
* @version
*/
public class Form_Preguntas extends MIDlet implements CommandListener {
private Command exitCommand;
private Display display;
private Form screen;
public TextField nombre;
static public String nombre2;
public Form_Preguntas()
{
String[] opciones = {"Chichina", "Chichino" , "Ni帽o" , "Peri" };
display = display.getDisplay(this);
exitCommand = new Command("Salir", Command.EXIT,2);
screen = new Form("PREGUNTAS IMPORTANTES");
StringItem Adivina = new StringItem("","Adivino quien Eres");
nombre = new TextField("Nombre","",30,TextField.ANY);
ChoiceGroup estado = new ChoiceGroup("Opciones",List.EXCLUSIVE,opciones,null);
screen.append(Adivina);
screen.append(nombre);
screen.append(estado);
screen.addCommand(exitCommand);
screen.setCommandListener(this);
// Alert alerta = new Alert ("Error","El dato no es v谩lido", null, AlertType.ERROR);
}
public void startApp() {
display.setCurrent(screen);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c,Displayable s){
if( c == exitCommand) {
// getString(nombre);
nombre2 = nombre.getString();
System.out.println(".:: CHichino ::."+nombre2);
System.out.println("ChiiiiiiiiiiichiiiiiiiiiiiiiiiiiNOOOOOOO");
pantalla tuino = new pantalla(nombre2);
display.setCurrent(tuino.Hola);
/*;
destroyApp(false);
notifyDestroyed();*/
}
}
}
este es el Otro formulario que no funciona COMMANDLISTENER
_______________________________________
import javax.microedition.lcdui.*;
public class pantalla implements CommandListener{
/** Creates a new instance of pantalla */
private Command exitCommand;
public Form Hola;
private Display display;
public pantalla() {
}
// display = display.getDisplay(this);
public pantalla(String A) {
Hola = new Form("PREGUNTAS IMPORTANTES");
if(A.equals("chichina"))
{
StringItem Adivina = new StringItem("","Adivino quien Eres :" + A);
Hola.append(Adivina);
}
StringItem Adivina2 = new StringItem("","ESTO es Una Prueba");
Hola.append(Adivina2);
Hola.addCommand(exitCommand);
Hola.setCommandListener(this);
}
public void commandAction(Command c,Displayable s){
if( c == exitCommand) {
System.out.println(".:: CHichino ::.");
// destroyApp(false);
// notifyDestroyed();
}
}
}
