Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
J2ME Form Class 
 

In this J2ME Extends Form example, we are going to discuss about form, extending form in our class and appending values to it.

 

J2ME Form Class

                         

In this J2ME Extends Form example, we are going to discuss about form, extending form in our class and appending values to it. But first of all lets discuss about form. In general, a form is a screen and this screen can contain any type of items such as images, text and text fields to get or show values to users. 

We can also set values into these forms using following syntax…

public int append(Item item)

The forgoing syntax can be used to add items into form in J2ME.

The application will look like as follow...

J2ME form class, append item example

In this image, "My Form" is a form created by us and "Hello Item" is a item that is appended in this form using append method.

Syntax of J2ME Form Class File name AppendItem.java

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

public class AppendItem extends MIDlet{
  private Display display;
  private MIDlet midlet;

  public void startApp(){
    Form form = new MyForm("MY FORM");
    display = Display.getDisplay(this);
    display.setCurrent(form);
  }

  public void pauseApp(){}

  public void destroyApp(boolean unconditional){}

  class MyForm extends Form implements CommandListener{
    private StringItem textItem;
    private Command exit;
    
    public MyForm(String title){
      super(title);
      exit = new Command("Exit", Command.BACK, 1);
      this.textItem = new StringItem (null, "Hello Item");
      addCommand(exit);
      append(this.textItem);
      this.setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d){
      String label = c.getLabel();
      if(label.equals("Exit")){
        midlet.notifyDestroyed();           
      }
    }
  }
}

Download Source Code

                         

» View all related tutorials
Related Tags: c j2me diff types type if example to rectangle draw exam raw angle e il pe in different m nt

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

please send me sajection

Posted by krishna on Wednesday, 12.3.08 @ 01:30am | #82305

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.