?? loginform.java
字號:
/*
* LoginForm.java
*
* Created on 2007年3月11日, 下午4:13
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package net.bccn.account.ui;
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 net.bccn.account.model.MySet;
import net.bccn.account.util.Record;
import net.bccn.account.util.Util;
/**
*
* @author hadeslee
*/
public class LoginForm extends Form implements CommandListener{
private Display dis;
private MySet my;
private TextField pwd;
private Command ok,cancel;
/** Creates a new instance of LoginForm */
public LoginForm(Display dis) {
super("登錄");
this.dis=dis;
}
//檢查一下是否需要密碼,如果不需要,則直接進入主畫面
public void check(){
Record[] rds=Util.getAllRecords(new MySet());
if(rds!=null&&rds.length>0){
my=(MySet)rds[0];
}
if(my==null||!my.getIsPwd()){
dis.setCurrent(MainForm.getInstance());
Util.main.isStart=true;
}else{
pwd=new TextField("請輸入密碼",null,8,TextField.PASSWORD);
this.append(pwd);
ok=new Command("確定",Command.OK,1);
cancel=new Command("退出",Command.EXIT,0);
this.addCommand(ok);
this.addCommand(cancel);
this.setCommandListener(this);
dis.setCurrent(this);
}
}
public void commandAction(Command command, Displayable displayable) {
if(command==ok){
String p=pwd.getString();
if(p==null||!p.equals(my.getPwd())){
Util.showINFO(AlertType.ERROR,"您的密碼有誤!!");
pwd.setString(null);
}else{
dis.setCurrent(MainForm.getInstance());
Util.main.isStart=true;
}
}else if(command==cancel){
Util.main.destroyApp(true);
Util.main.notifyDestroyed();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -