📄 modifypassword.java
字号:
/** * <p>Title: CowriePixie</p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: xidian</p> * @author yangyong * @version 1.0 */import javax.microedition.lcdui.Alert;import javax.microedition.lcdui.AlertType;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.rms.RecordStore;/* * 创建日期 2005-9-23 * * TODO 要更改此生成的文件的模板,请转至 * 窗口 - 首选项 - Java - 代码样式 - 代码模板 *//** * @author Administrator * * TODO 要更改此生成的类型注释的模板,请转至 * 窗口 - 首选项 - Java - 代码样式 - 代码模板 */public class ModifyPassword extends Form implements CommandListener { private Command ok; private Command back; private TextField pswone; private TextField pswtwo; private Display dis; private String psw1; private String psw2; protected RecordStore pswdb; public ModifyPassword(Display display) { super("修改密码"); psw1 = new String(); psw2 = new String(); dis = display; try { append(Financing.secur); } catch(Exception exception) { } pswone = new TextField("输入新密码", null, 6, TextField.PASSWORD);//密码输入最多为6位字符 append(pswone); pswtwo = new TextField("确认新密码", null, 6, TextField.PASSWORD);//确认密码为6位 append(pswtwo); ok = new Command("修改", Command.OK, 2); addCommand(ok); back = new Command("返回",Command.BACK, 2); addCommand(back); setCommandListener(this); } public void commandAction(Command c, Displayable d) { if(c == back) { Main_Form mainform = new Main_Form(dis); dis.setCurrent(mainform); return; } if(c == ok) { psw1 = pswone.getString(); psw2 = pswtwo.getString(); if(psw1.equals(psw2)) { //通过RMS保存修改的密码. UpdatePassword(); try { Alert alert = new Alert("提示", " 密码更新完毕", Financing.alert, AlertType.ALARM); alert.setTimeout(500); dis.setCurrent(alert); Main_Form mainform = new Main_Form(dis); dis.setCurrent(mainform); return; } catch(Exception exception) { } } else { Alert alert = new Alert("告警", " 密码输入有误,请重输", Financing.alert, AlertType.ALARM); alert.setTimeout(500); dis.setCurrent(alert); pswone.setString(null); pswtwo.setString(null); } } } //密码保存至以pswdb为名RecordStore中. void UpdatePassword() { String filename = "psw"; byte psw[] = new byte[8]; try { pswdb = RecordStore.openRecordStore(filename, true); } catch(Exception ex) { return; } try { byte temp[] = psw1.getBytes(); pswdb.setRecord(1, temp, 0, temp.length); } catch(Exception exception) { } try { pswdb.closeRecordStore(); } catch(Exception exception1) { } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -