Kamis, 11 November 2010

Membuat Data Diri Dengan Java ME

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package datadiri;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;


/**
 * @author sophie
 */
public class DataDiriDemo extends MIDlet implements CommandListener{
    private static final Command CMD_EXIT = new Command ("Exit",Command.EXIT, 1);
    private static final Command CMD_OK = new Command ("Exit",Command.OK, 2);
    public static final String[] gender = {"Laki-Laki","Perempuan"};
    private boolean firstTime;
    private Form mainForm;

    private Display display;

    public DataDiriDemo() {
        firstTime = true;
        mainForm = new Form ("Data Diri");
    }

    public void startApp() {
        display = Display.getDisplay (this);
        if(firstTime){
            mainForm.append(new TextField("Nama","",15,TextField.ANY));
            mainForm.append(new TextField("Telepon","",15,TextField.PHONENUMBER));
            ChoiceGroup jenis =new ChoiceGroup ("Jenis Kelamin", ChoiceGroup.EXCLUSIVE,gender,null);
            mainForm.append(jenis);

            mainForm.append(new DateField("Tanggal Lahir", DateField.DATE));

            mainForm.addCommand(CMD_EXIT);
            mainForm.setCommandListener(this);
            firstTime = false;
        }
        Display.getDisplay(this).setCurrent(mainForm);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if (c == CMD_EXIT) {
            destroyApp(false);
            notifyDestroyed();
        }
       
    }
}

0 komentar:

Posting Komentar