Quote:
import javax.microedition.midlet.*;
import VsaoLib.DangkyTV;
import java.util.*;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
/**
* @author Kien
*/
public class Vsao extends MIDlet implements CommandListener {
private DangkyTV newDK1, newDK2, newDK3;
private Command mDangky, mDangnhap, mBack, mNext, mOk, mExit, mChoice;
private Form mF1, mF2, mF3, mF4;
private String tb1, tb2;
private TextField user, pass;
private Alert error;
private String url, testUser, testPass;
public Vsao(){
user = new TextField("E-Mail:", "", 100, TextField.ANY);
pass = new TextField("Pass word:", "", 16, TextField.PASSWORD);
tb1 = new String("Chao mung ban den voi Vsao");
error = new Alert("Dang ky khong dung", "Hay nhap dung dia chi email va"
+ " pass word", null, AlertType.ERROR);
mDangky = new Command("Dang ky", Command.SCREEN, 1);
mDangnhap = new Command("Dang nhap", Command.SCREEN, 1);
mBack = new Command("Quay lai", Command.BACK, 1);
mOk = new Command("Hoan thanh", Command.OK, 0);
mExit = new Command("Thoat ra", Command.EXIT, 1);
mNext = new Command("Tiep tuc", Command.SCREEN, 1);
mChoice = new Command("Lua chon", Command.OK, 1);
testUser = user.getString();
testPass = pass.getString();
}
public void startApp() {
mF1 = new Form("Vsao xin chao");
mF1.append(tb1);
mF1.addCommand(mDangky);
mF1.addCommand(mDangnhap);
mF1.setCommandListener(this);
Display.getDisplay(this).setCurrent(mF1);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void closeApp(){
/*
* Kiem tra che do app dang chay, neu con truy cap thi dong truy cap
* sau do tien hanh dong app
*/
destroyApp(true);
notifyDestroyed();
}
public void commandAction(Command c, Displayable d){
if (c == mDangky) {
newDK1 = new DangkyTV("Dang Ky"); //tin nhan 1
newDK1.send("DK1", "8047");
HienthiMF3();//form dang ky user
}
else if (c == mNext)
{
TestValue(user);
}
else if (c == mOk) {
TestPass(pass);
HienthiMF2();//Display Mf2
}
else if (c == mBack){
HienthiMF2();
}else if(c == mDangnhap){
HienthiMF2();//Display mF2
}
else if(c == mExit){
closeApp();
}
}
public void TestValue(TextField value){
this.user = value;
if ((user.getString().equals("")))//phai bat ngoai le cho message
{
error.setTimeout(Alert.FOREVER);
Display.getDisplay(this).setCurrent(error, mF3);
} else{
SendUser();//send message with username = value of TextField
HienthiMF4();
}
TestValue(value);
}
public void TestPass(TextField pass1){
this.pass = pass1;
if (pass.getString().equals("")){
Display.getDisplay(this).setCurrent(error, mF4);
} else{
SendPass();//send message with pass = value of TextField
}
//TestPass(pass1);
}
public void HienthiMF3(){//Display MF3
mF3 = new Form("Dang Ky Thanh Vien");
mF3.append(user);
mF3.addCommand(mNext);
mF3.addCommand(mBack);
mF3.setCommandListener(this);
Display.getDisplay(this).setCurrent(mF3); //hien thi man hinh chính mF1
}
public void HienthiMF4(){//Display MF4
mF4 = new Form("Dang Ky Thanh Vien");
mF4.append(pass);
mF4.addCommand(mOk);
mF4.addCommand(mBack);
mF4.setCommandListener(this);
Display.getDisplay(this).setCurrent(mF4);
}
public void HienthiMF2(){
mF2 = new Form("Chao mung ban da den voi Vsao");
mF2.addCommand(mExit);
mF2.addCommand(mChoice);
mF2.setCommandListener(this);
//mF2 ket noi toi Wap
Display.getDisplay(this).setCurrent(mF2);
}
public void SendUser(){//send Message to gateway
newDK2 = new DangkyTV("User name");
newDK2.send(testUser, "8047");
}
public void SendPass(){
newDK3 = new DangkyTV("pass"); //DangkyTV extends Sender class
newDK3.send(testPass, "8047");
}
}
I don't understand my Error, please help me, Thanks!