menu login |
menu set jadwal |
ini langsung aja copy sourcenya:
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
/**
* Pembuat : Genli wahyu saputra
*/
public class Midlet extends MIDlet implements CommandListener{
private Display display;
private TextField userName,password;
public Form form,form1;
private Command login,cancel;
private Command add=new Command("Set", Command.OK, 1);
private Command simpan=new Command("save", Command.OK, 2);
private Command kembali=new Command("back", Command.BACK, 1);
private List listmenu;
private Image img,imge,img2;
private TextField hari,jam,namaless;
public Midlet() {
form = new Form("Sign in");
userName = new TextField("LoginID:", "", 30, TextField.ANY);
password = new TextField("Password:", "", 30, TextField.PASSWORD);
cancel = new Command("Sing Out", Command.CANCEL, 2);
login = new Command("Login", Command.OK, 2);
}
public void startApp() {
display = Display.getDisplay(this);
try{form.append(img);}catch(Exception e){}
form.append(userName);
form.append(password);
form.addCommand(cancel);
form.addCommand(login);
form.setCommandListener(this);
display.setCurrent(form);
}
public void menu(){
listmenu=new List("jadwal", List.IMPLICIT);
listmenu.append("senin", null);
listmenu.append("selasa", null);
listmenu.addCommand(add);
listmenu.addCommand(cancel);
listmenu.setCommandListener(this);
display.setCurrent(listmenu);
}
public void setjadwal(){
form1=new Form("menu");
hari=new TextField("nama", "", 20, TextField.ANY);
jam=new TextField("pukul", "", 20, TextField.ANY);
namaless=new TextField("mata pelajaran", "", 20,TextField.ANY);
form1.append(hari);
form1.append(jam);
form1.append(namaless);
form1.addCommand(simpan);
form1.addCommand(kembali);
form1.setCommandListener(this);
display.setCurrent(form1);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void validateUser(String name, String password) {
if (name.equals("genli") && password.equals("cool")) {
menu();
} else {
tryAgain();
}
}
public void showMsg() {
Alert success = new Alert("Login Successfully",
"Your Login Process is completed!",
img2, AlertType.INFO);
success.setImage(img2);
userName.setString("");
password.setString("");
display.setCurrent(success, form);
}
public void tryAgain() {
Alert error = new Alert("Login Incorrect", "Please try again", imge, AlertType.ERROR);
error.setTimeout(900);
error.setImage(imge);
userName.setString("");
password.setString("");
display.setCurrent(error, form);
}
public void commandAction(Command c, Displayable d) {
String label = c.getLabel();
if(label.equals("Cancel")) {
destroyApp(true);
} else if(label.equals("Login")) {
validateUser(userName.getString(), password.getString());
}else if (c==add){
setjadwal();
}else if (c==kembali){
menu();
}
}
}
selamat mencoba semoga bermanfaat ^_^
import javax.microedition.lcdui.*;
/**
* Pembuat : Genli wahyu saputra
*/
public class Midlet extends MIDlet implements CommandListener{
private Display display;
private TextField userName,password;
public Form form,form1;
private Command login,cancel;
private Command add=new Command("Set", Command.OK, 1);
private Command simpan=new Command("save", Command.OK, 2);
private Command kembali=new Command("back", Command.BACK, 1);
private List listmenu;
private Image img,imge,img2;
private TextField hari,jam,namaless;
public Midlet() {
form = new Form("Sign in");
userName = new TextField("LoginID:", "", 30, TextField.ANY);
password = new TextField("Password:", "", 30, TextField.PASSWORD);
cancel = new Command("Sing Out", Command.CANCEL, 2);
login = new Command("Login", Command.OK, 2);
}
public void startApp() {
display = Display.getDisplay(this);
try{form.append(img);}catch(Exception e){}
form.append(userName);
form.append(password);
form.addCommand(cancel);
form.addCommand(login);
form.setCommandListener(this);
display.setCurrent(form);
}
public void menu(){
listmenu=new List("jadwal", List.IMPLICIT);
listmenu.append("senin", null);
listmenu.append("selasa", null);
listmenu.addCommand(add);
listmenu.addCommand(cancel);
listmenu.setCommandListener(this);
display.setCurrent(listmenu);
}
public void setjadwal(){
form1=new Form("menu");
hari=new TextField("nama", "", 20, TextField.ANY);
jam=new TextField("pukul", "", 20, TextField.ANY);
namaless=new TextField("mata pelajaran", "", 20,TextField.ANY);
form1.append(hari);
form1.append(jam);
form1.append(namaless);
form1.addCommand(simpan);
form1.addCommand(kembali);
form1.setCommandListener(this);
display.setCurrent(form1);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void validateUser(String name, String password) {
if (name.equals("genli") && password.equals("cool")) {
menu();
} else {
tryAgain();
}
}
public void showMsg() {
Alert success = new Alert("Login Successfully",
"Your Login Process is completed!",
img2, AlertType.INFO);
success.setImage(img2);
userName.setString("");
password.setString("");
display.setCurrent(success, form);
}
public void tryAgain() {
Alert error = new Alert("Login Incorrect", "Please try again", imge, AlertType.ERROR);
error.setTimeout(900);
error.setImage(imge);
userName.setString("");
password.setString("");
display.setCurrent(error, form);
}
public void commandAction(Command c, Displayable d) {
String label = c.getLabel();
if(label.equals("Cancel")) {
destroyApp(true);
} else if(label.equals("Login")) {
validateUser(userName.getString(), password.getString());
}else if (c==add){
setjadwal();
}else if (c==kembali){
menu();
}
}
}
selamat mencoba semoga bermanfaat ^_^
No comments:
Post a Comment
Udah di baca kan.... kritik dan sarannya saya persilahkan ^_^..jangan lupa isi Buku tamunya juga ya...