📄 personalinfoform.java
字号:
import java.io.IOException;
import java.util.Enumeration;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.TextField;
//个人信息界面
public class PersonalInfoForm extends Form implements CommandListener
{
private Command cancel;
private Command ok;
private TextField realName;
private TextField age;
private User user;
public PersonalInfoForm(String title, User user)
{
super(title);
this.user = user;
cancel = new Command("取消", Command.CANCEL, 1);
ok = new Command("确定", Command.OK, 1);
realName = new TextField("真实姓名:", user.getRealName(), 20, TextField.ANY);
age = new TextField("年龄:", Integer.toString(user.getAge()), 20, TextField.NUMERIC);
this.append(realName);
this.append(age);
this.addCommand(cancel);
this.addCommand(ok);
this.setCommandListener(this);
}
public void commandAction(Command c, Displayable d)
{
if (c.equals(cancel))
{
MyLoginMIDlet.midlet.showWelcomeList(this.user);
}
else if (c.equals(ok))
{
String rn = realName.getString();
int age = Integer.parseInt(this.age.getString());
int index = MyLoginMIDlet.userList.indexOf(this.user);
this.user.setRealName(rn);
this.user.setAge(age);
MyLoginMIDlet.userList.setElementAt(this.user, index);
Alert al = new Alert("个人信息修改", this.user.getUserName()+"个人信息修改成功!", null, AlertType.INFO);
al.setTimeout(2000);
WelcomeList list = new WelcomeList(user.getUserName()+",欢迎光临!",Choice.IMPLICIT, user);
MyLoginMIDlet.midlet.showAlert(al, list);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -