📄 modifyrecordform.java
字号:
package ch12;
import javax.microedition.lcdui.*;
public class ModifyRecordForm
extends Form
implements CommandListener {
//声明一个Display对象
private Display display;
//声明一个Displayable对象承载父窗体
private Displayable parent;
//声明一个代表记录中姓名的文本域TextField
private TextField nameTextField;
//声明一个代表记录中积分的文本域TextField
private TextField scoreTextField;
//声明一个代表记录中排名的文本域TextField
private TextField rankTextField;
//声明一个代表记录中日期的文本域TextField
private TextField dateTextField;
//声明一个返回上一级窗体按钮Command对象
private Command backCommand;
//声明一个确认按钮Command对象
private Command okCommand;
//声明一个代表记录ID号的StringItem
private StringItem idStringItem;
/*
1.构造器
*/
public ModifyRecordForm(Display d, Displayable p, int id, String name,
String score, String rank, String date) {
super("修改信息");
display = d;
parent = p;
idStringItem = new StringItem("ID 号码", id + "");
nameTextField = new TextField("姓名", name, 30, TextField.ANY);
scoreTextField = new TextField("积分", score, 16, TextField.NUMERIC);
rankTextField = new TextField("名次", rank, 16, TextField.NUMERIC);
dateTextField = new TextField("日期", date, 16, TextField.ANY);
append(idStringItem);
append(nameTextField);
append(scoreTextField);
append(rankTextField);
append(dateTextField);
backCommand = new Command("返回", Command.BACK, 1);
okCommand = new Command("确认", Command.OK, 1);
addCommand(backCommand);
addCommand(okCommand);
setCommandListener(this);
}
/*
2.响应按钮事件
*/
public void commandAction(Command c, Displayable s) {
if (c == backCommand) {
display.setCurrent(parent);
}
else {
RecordDB rdb = new RecordDB();
int _id = Integer.parseInt( (idStringItem.getText()));
String _name = nameTextField.getString();
String _score = scoreTextField.getString();
String _rank = rankTextField.getString();
String _date = dateTextField.getString();
rdb.modifyRecord(_id, _name, _score, _rank, _date);
rdb.closeRS();
display.setCurrent(parent);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -