- Pizza or Burger?
- If it's Pizza, ask for each of the following toppings: pepperoni, sausage, anchovies
- If Burger, ask for cheese and onions
I'm trying to construct separate alerts or change the String property of a given alert. I'm also trying to use the Commannd object with the alert.
However, this is what I have so far, and it appears that I have gotten it all wrong:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author Class
*/
public class AlertMidlet extends MIDlet implements CommandListener {
Alert mymsg,mymsg2;
Display disp;
Command nextalert;
Form myform;
TextField username, password;
public AlertMidlet() {
mymsg = new Alert("PIZZA");
mymsg.setString("I would like a pizza with pepperoni, sausage,"
+ "and anchovies.");
mymsg.setTimeout(10000);
mymsg2 = new Alert("BURGER");
mymsg2.setString("I would like a burger with onions and cheese.");
nextalert = new Command("Next Alert",Command.OK,0);
mymsg.addCommand(nextalert);
mymsg.setCommandListener(this);
myform = new Form("Our First Form");
username = new TextField("Username", "", 10,TextField.ANY);
myform.append(username);
password = new TextField("Password", "", 10,TextField.PASSWORD);
myform.append(password);
myform.addCommand(nextalert);
myform.setCommandListener(this);
//
}
public void startApp() {
disp = Display.getDisplay(this);
disp.setCurrent(myform);
}
public void commandAction(Command c, Displayable d) {
if ((c == nextalert) && (d == myform)) {
if (username.getString().equals(password.getString())) {
disp.setCurrent(mymsg);
} else {
disp.setCurrent(mymsg2);
}
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
I've even tried Yahoo! Answers to help me with this, but so far, I've gotten no luck on it.
I'm looking for any hints/ideas to make this MIDlet work properly.

New Topic/Question
Reply



MultiQuote







|