Subscribe to RSS Feed

Jumat, 08 Juni 2012

Tulisan 14: Contoh Program TextBox J2ME

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

public class cthTextBox extends MIDlet implements CommandListener
{
Display display;
Alert txtpesan;
Command cmdExit;
Command cmdOk;
TextField txtnama;
TextField txtpass;
Form Form;

public cthTextBox() {}
public void startApp()
{
Form = new Form("UserLogin");
txtnama = new TextField("Nama","",50,TextField.ANY);
txtpass = new TextField("Password","",50,TextField.PASSWORD);
cmdExit=new Command("Exit", Command.EXIT,0);
cmdOk=new Command("Ok", Command.OK,0);
Form.addCommand(cmdExit);
Form.addCommand(cmdOk);
Form.append(txtnama);
Form.append(txtpass);
display=Display.getDisplay(this);
display.setCurrent(Form);
Form.setCommandListener(this);
}

public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command c, Displayable d)
{
if(c==cmdExit)
{
destroyApp(false);
notifyDestroyed();
}
else if(c==cmdOk)
{
txtpesan=new Alert("Pesan");
txtpesan.setString("Data Telah Disimpan");
display.setCurrent(txtpesan);
}
}
}

0 komentar:

Posting Komentar