Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
Guesuper Guesuper is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 408
Rep Power: 14
Guesuper mempunyai hidup yang Normal
Default Form Login J2ME

import javax.microedition.midlet.MIDlet;

05.import javax.microedition.lcdui.*;

06.

07.public class login extends MIDlet implements CommandListener {

08.private Display display;

09.private TextField userName;

10.private TextField password;

11.private Form form;

12.private Command cancel;

13.private Command login;

14.





15.public login() {

16.userName = new TextField("LoginID :", "", 10, TextField.ANY);

17.password = new TextField("Password :", "", 10, TextField.PASSWORD);

18.form = new Form("Login");

19.cancel = new Command("Cancel", Command.CANCEL, 2);

20.login = new Command("Login", Command.OK, 2);

21.}

22.

23.public void startApp() {

24.form.setTitle("Silakan Login");

25.form.append(userName);

26.form.append(password);

27.form.addCommand(cancel);

28.form.addCommand(login);

29.form.setCommandListener(this);

30.display.setCurrent(form);

31.}

32.

33.public void pauseApp() {

34.}

35.

36.public void destroyApp(boolean unconditional) {

37.notifyDestroyed();

38.}

39.

40.public void validateUser(String name, String password) {

41./** "usernya" dan "passwordnya" bisa diganti sesuai keinginan*/

42.if (name.equals("usernya") && password.equals("passwordnya")) {

43.bener();

44.} else {

45.tryAgain();

46.}

47.}

48.

49.public void bener() {

50.Alert benar = new Alert("Login Sukses", "Selamat Login Sukses", null, AlertType.ERROR);

51.error.setTimeout(Alert.FOREVER);

52.display.setCurrent(error);

53.}

54.

55.public void tryAgain() {

56.Alert salah = new Alert("Login salah", "Silakan Ulangi lagi", null, AlertType.ERROR);

57.salah.setTimeout(Alert.FOREVER);

58.userName.setString("");

59.password.setString("");

60.display.setCurrent(salah, form);

61.}

62.

63.public void commandAction(Command c, Displayable d) {

64.String label = c.getLabel();

65.if(label.equals("Cancel")) {

66.destroyApp(true);

67.} else if(label.equals("Login")) {

68.validateUser(userName.getString(), password.getString());







Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 11:35 AM.


no new posts