Add controls to form : Form « J2ME « Java Tutorial






Add controls to form
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;

public class FormExampleMIDlet extends MIDlet {
    protected Display display;
    protected boolean started;
    
    protected void startApp() {
        if (!started) {
            display = Display.getDisplay(this);
            
            Form form = new Form("Item Layout");
            
            form.append("line");
            
            form.append(new TextField("Name", "J. Doe", 32, TextField.ANY));
            form.append("Address");
            form.append(new TextField(null, null, 32, TextField.ANY));            
            
            display.setCurrent(form);
            
            started = true;
        }
    }

    protected void pauseApp() {
    }

    protected void destroyApp(boolean unconditional) {
    }
}








31.3.Form
31.3.1.Form demoForm demo
31.3.2.extends Form to create a new formextends Form to create a new form
31.3.3.Add controls to formAdd controls to form
31.3.4.GUI testGUI test
31.3.5.Add or remove controls from a form
31.3.6.creates a Form with two items, an interactive Gauge and a StringItemcreates a Form with two items, an interactive Gauge and a StringItem