日期:2014-05-20 浏览次数:20741 次
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class Delete extends MIDlet implements CommandListener{
private Form form = new Form("“清除”要怎么用?请教各位大虾");
private Display dis;
private TextField user = new TextField("用户名:","",20,TextField.ANY );
private TextField pass = new TextField("密码:","",20,TextField.PASSWORD );
private Command cmdDel = new Command("清除",Command.SCREEN,1);
int position;
protected void startApp() throws MIDletStateChangeException {
dis = Display.getDisplay(this);
dis.setCurrent(form);
form.append(user);
form.append(pass);
form.addCommand(cmdDel);
form.setCommandListener(this);
}
public void commandAction(Command c, Displayable d) {
if(c==cmdDel){
if("什么"=="用户名"){
position = user.getCaretPosition();
user.delete(position-1, 1);
}
else if("什么"=="密码"){
position = pass.getCaretPosition();
pass.delete(position-1, 1);
}
}
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
}
if(c==cmdDel){
if("什么"=="用户名"){
position = user.getCaretPosition();
user.delete(position-1, 1);
}
else if("什么"=="密码"){
position = pass.getCaretPosition();
pass.delete(position-1, 1);
}
}