J2ME tutorial-Form


Using Form

Form is an import item to display on the screen. A form can contain other items such as text field, command button, list, image, etc.

To display a form, first you need to create its object.


Form form1=new Form("Form1");

This will create a form object named form1. The "Form1" text is the title of the form. You can see this text at the top left corner of the form window.

To display the form on the screen you need to assign the form name as the parameter of setCurrent method of the display object.

Display display=Display.getDisplay(this);



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

public class Firstprogram extends MIDlet implements CommandListener {
private Display display;
private Form form1;

public Firstprogram() {
display = Display.getDisplay(this);//create display object


public void startApp() {
form1=new Form("Form1");//create form1 object
display.setCurrent(form1);//display the form


public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

public void commandAction(Command c, Displayable s) {}




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.