Nama : Gusty Cholid Fahrudi
NIM : E3210320
Prodi : TKK-A
Aplikasi Mobile TextBox
1. Pertama kita jalankan dulu Java Netbeans 7.1, Kemudian buat project baru. ikuti seperti gambar dibawah ini....
2. Cara Membuat Midlet baru
3. Cara Membuat Class Baru
4. Cara Membuat Package Baru
5.Setelah anda membuat class Input
( Isikan Class Input Dengan Script tersebut )
package pkgprak2;
import javax.microedition.lcdui.*;
public class FormInput extends Form {
private TextField tfNama, tfEmail;
public FormInput() {
super("Input Data");
tfNama = new TextField("Nama Anda", null, 15, TextField.ANY);
tfEmail = new TextField("Email", null, 15, TextField.EMAILADDR);
append(tfNama);
append(tfEmail);
}
public String getNama() {
return tfNama.getString();
}
public String getEmail() {
return tfEmail.getString();
}
}
6. Setelah Membuat Class FormShow1
(Isikan Class Form1 Dengan script tersebut)
package pkgprak2;
import javax.microedition.lcdui.*;
public class FormShow1 extends Form {
private StringItem stNama, stEmail;
public FormShow1() {
super("Tampil 1");
stNama = new StringItem("Nama:", null);
stEmail = new StringItem("Email", null);
append(stNama);
append(stEmail);
}
public void setNama(String nama) {
stNama.setText(nama);
}
public void setEmail(String email) {
stEmail.setText(email);
}
}
7. Setelah Membuat Class FormShow2
(Isikan Class Form2 dengan Script tersebut)
package pkgprak2;
import javax.microedition.lcdui.*;
public class FormShow2 extends TextBox{
public FormShow2() {
super("Tampil 2", null, 30, 0);
}
public void setTextBox(String isi) {
this.setString(isi);
}
}
8.Setelah Itu Membuat Midlet
(Isikan Halaman Midlet Dengan Script tersebut)
package pkgprak2;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class Prak2Midlet extends MIDlet implements CommandListener {
private FormInput frmInput;
private FormShow1 frmShow1;
private FormShow2 frmShow2;
private Command cmShow1, cmShow2, cmBack, cmExit;
public void startApp() {
if (frmInput == null)
frmInput = new FormInput();
if (frmShow1 == null)
frmShow1 = new FormShow1();
if (frmShow2 == null)
frmShow2 = new FormShow2();
cmShow1 = new Command("Show 1", Command.OK, 0 );
cmShow2 = new Command("Show 2", Command.OK, 1 );
cmBack = new Command("Kembali", Command.BACK, 0 );
cmExit = new Command("Keluar", Command.EXIT, 0 );
frmInput.addCommand(cmShow1);
frmInput.addCommand(cmShow2);
frmInput.addCommand(cmExit);
frmShow1.addCommand(cmBack);
frmShow2.addCommand(cmBack);
frmInput.setCommandListener(this);
frmShow1.setCommandListener(this);
frmShow2.setCommandListener(this);
Display.getDisplay(this).setCurrent(frmInput);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (d == frmInput) {
if (c == cmExit) {
destroyApp(true);
notifyDestroyed();
}
if (c == cmShow1) {
frmShow1.setNama(frmInput.getNama());
frmShow1.setEmail(frmInput.getEmail());
Display.getDisplay(this).setCurrent(frmShow1);
}
if (c == cmShow2) {
frmShow2.setTextBox(frmInput.getNama() + "\n" + frmInput.getEmail());
Display.getDisplay(this).setCurrent(frmShow2);
}
}
if (d == frmShow1) {
if ( c == cmBack) {
Display.getDisplay(this).setCurrent(frmInput);
}
}
if (d == frmShow2) {
if ( c == cmBack) {
Display.getDisplay(this).setCurrent(frmInput);
}
}
}
}
9. Kemudian Setelah Selesai semuanya anda jalankan programnya
Akan Muncul Seperti ini.
Gambar Inputan
Gambar Tampilan Form1
Gambar TextBox
Jika anda kurang paham silakan komentar di sini......



sepi gan.....
BalasHapus