📄 phaserenameform.java
字号:
import javax.microedition.lcdui.*;
public class PhaseRenameForm extends Form implements CommandListener
{
private RestRecord restRecord;
private Command back, save;
private TextField field;
private String oldName, newName;
private StringItem tempItem = null;
private PhaseListForm phaseListForm = null;
public PhaseRenameForm(StringItem i,RestRecord rr,PhaseListForm plf)
{
super("输入新名称");
tempItem = i;
oldName = tempItem.getText();
restRecord = rr;
phaseListForm=plf;
back = new Command("Back",Command.EXIT,1);
save = new Command("Save",Command.OK,1);
field=new TextField("输入新名称","",10,TextField.ANY);
addCommand(back);
addCommand(save);
append(field);
setCommandListener(this);
}
public void commandAction(Command com, Displayable dis)
{
if(com == back)
{
Chess.dis.setCurrent(phaseListForm);
}
if(com == save)
{
newName = field.getString();
if(newName.length()<1||newName.length()>10)
{
Alert alert=new Alert("Message","长度在1到10之间",null,AlertType.WARNING);
Chess.dis.setCurrent(alert, this);
}
else
{//经常会返回3,但结果却正确
int flag = restRecord.renamePhase(oldName ,newName);
//if(flag == 0)
//{
tempItem.setText(newName);
Chess.dis.setCurrent(phaseListForm);
//}
/*else
{
System.out.println(flag);
Alert alert=new Alert("Message","残局重命名失败",null,AlertType.WARNING);
Chess.dis.setCurrent(alert,this);
}*/
}
}
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -