السلام عليكم,
بعد جهد كبير في البحث و التجريب لم أتوصل الى الحل الصحيح.
الأخوان الكرام خبراء J2ME الرجاء التفضل علي و تجريب هذا البرنامج على الهاتف!!!!!
علماً بأنه يشغله ktoolbar و لا يجد فيه أي خطأ..!؟ و لكنه غير مقبول بالنسبه لمشغل الجافا في الهاتف!
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class LoginRami extends MIDlet implements CommandListener {
Display display;
TextField userName;
TextField password;
Form form;
Command cancel;
Command login;
public LoginRami( ) {
userName = new TextField("اسم المستخدم:", "", 10, TextField.ANY);
password = new TextField("كلمة السر:", "", 10, TextField.PASSWORD);
form = new Form("التسجيل");
cancel = new Command("الغاء", Command.CANCEL, 2);
login = new Command("تسجيل", Command.OK, 2);
}
public void startApp( ) {
display = Display.getDisplay(this);
form.append(userName);
form.append(password);
form.addCommand(cancel);
form.addCommand(login);
form.setCommandListener(this);
display.setCurrent(form);
}
public void pauseApp( ) {}
public void destroyApp(boolean unconditional) {
notifyDestroyed( );
}
public void validateUser(String name, String password) {
if (name.equals("a1") && password.equals("1a")) {
form.deleteAll(); // غير مقبولة في الهاتف
form.removeCommand(login);
menu( );
}
else {
tryAgain( );
}
}
public void menu( ) {
form.setTitle("Logo"); // غير مقبولة في الهاتف
try{
Image img = Image.createImage("/Rami.png"); // طبيعي لا تنسى تغير اسم الصورة
form.append(img);
} catch (java.io.IOException e)
{
Alert alert = new Alert ( "خطأ في تحميل الصورة" );
alert.setString( e.getMessage() );
display.setCurrent(alert);
}
}
public void tryAgain( ) {
Alert error = new Alert("خطأ في التسجيل", "حاول مرة أخرى", null, AlertType.ERROR);
error.setTimeout(Alert.FOREVER);
userName.setString("");
password.setString("");
display.setCurrent(error, form);
}
public void commandAction(Command c, Displayable d) {
String rami = c.getLabel( );
if (rami.equals("الغاء")) {
destroyApp(true);
}
else
if (rami.equals("تسجيل")) {
validateUser(userName.getString(), password.getString( ));
}
}
}ما هي الطريقة الصحيحة التي يقبلها مشغل الجافا في الهاتف, لحذف كامل محتويات الفورم ( لإستبدالها بأخرى ). " علماُ الهاتف هو نوكيا 6610 "
و لكم الشكر سلفاً.
رامي