Form can be considered as a page for entering data. form may consist of components commonly referred to as items. collection of items that exist in a form on the concept stored in the array, so that accessing can be done using the index. The following example Form program in java MIDlet.
1 import javax.microedition.midlet.*;
2 import javax.microedition.lcdui.*;
3
4 public class FormDemo extends MIDlet implements CommandListener
5 {
6 private Form form;
7 private Display display;
8 private Command cmdKeluar;
9
10 public FormDemo () {
11 }
12
13 public void startApp() {
14 form = new Form("Latihan Membuat Form");
15 form.append("MIDlet pertamaku!");
16 display=Display.getDisplay(this);
17 display.setCurrent(form);
18
19 cmdKeluar = new Command ("Keluar", Command.EXIT, 0);
20 form.addCommand(cmdKeluar);
21 form.setCommandListener(this);
22 }
23
24 public void pauseApp() {
25 }
26
27 public void destroyApp(boolean unconditional) {
28 notifyDestroyed();
29 }
30
31 public void commandAction(Command c, Displayable d ) {
32 if ( c == cmdKeluar ) {
33 destroyApp(true);
34 }
35 }
36 }
2 import javax.microedition.lcdui.*;
3
4 public class FormDemo extends MIDlet implements CommandListener
5 {
6 private Form form;
7 private Display display;
8 private Command cmdKeluar;
9
10 public FormDemo () {
11 }
12
13 public void startApp() {
14 form = new Form("Latihan Membuat Form");
15 form.append("MIDlet pertamaku!");
16 display=Display.getDisplay(this);
17 display.setCurrent(form);
18
19 cmdKeluar = new Command ("Keluar", Command.EXIT, 0);
20 form.addCommand(cmdKeluar);
21 form.setCommandListener(this);
22 }
23
24 public void pauseApp() {
25 }
26
27 public void destroyApp(boolean unconditional) {
28 notifyDestroyed();
29 }
30
31 public void commandAction(Command c, Displayable d ) {
32 if ( c == cmdKeluar ) {
33 destroyApp(true);
34 }
35 }
36 }
Output :
0 komentar:
Post a Comment
Silahkan berkomentar, namun tetap jaga kesopanan dengan tidak melakukan komentar spam, dan tuliskan nama jelas.