Sou iniciante, comecei a mexer com java essa madrugada, pra tentar fazer alguma coisa no J2ME, e nunca programei em java antes.
Fiz uma coisa simples baseado em outros exemplos e gostaria de pedir ajuda no if (q absurdo, mas eh verdade)
Ai ta:
import javax.microedition.lcdui.;
import javax.microedition.midlet.;
public class MyPasswords extends MIDlet implements CommandListener
{
Display tela;
Form login, resultado;
TextField senha;
StringItem resultadoMsg;
Command sair, prox;
ImageItem imgi;
public MyPasswords() {
this.sair = new Command("Sair", Command.EXIT, 0);
this.prox = new Command("Ok", Command.SCREEN, 1);
this.login = new Form("Login");
this.senha = new TextField("Senha:", "", 5, TextField.NUMERIC | TextField.PASSWORD);
this.login.append(this.senha);
this.login.addCommand(this.sair);
this.login.addCommand(this.prox);
this.login.setCommandListener(this);
this.resultado = new Form("Resultado");
this.resultadoMsg = new StringItem("","");
this.resultado.append(this.resultadoMsg);
this.resultado.addCommand(this.sair);
this.resultado.setCommandListener(this);
}
public void startApp() {
this.tela = Display.getDisplay(this);
this.tela.setCurrent(this.login);
}
public void pauseApp() {
}
public void destroyApp(boolean i) {
}
public void commandAction(Command c, Displayable d) {
if (c == this.sair) {
this.destroyApp(true);
this.notifyDestroyed();
}
if (c == this.prox) {
this.resultadoMsg.setLabel("Resultado: ");
this.resultadoMsg.setText("ERRO");
String str = this.senha.getString();
[b]if (str=="12345") {
this.resultadoMsg.setText("OK");
}[/b]
this.tela.setCurrent(this.resultado);
}
}
}
Bem, o que tenho q fazer pra esse teste funcionar? ja que não funcionou comigo? Desculpem a ignorancia, mas n sei mesmo.
Vlw ae…