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

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
J2ME Command Class 
 

In the given J2ME Command Class example, we have set the various commands namely, screen, back, cancel, ok, help, stop, exit and item to the Midlet.

 

J2ME Command Class

                         

In the given J2ME Command Class example, we have set the various commands namely, screen, back, cancel, ok, help, stop, exit and item to the Midlet. And also set the priority for it such as 1, 2, 3 etc. In J2ME commands are used for keeping information of the commands, not the action. For defining actions, CommandListener class are used. In this example we are going to show different commands on the screen but we have not used CommandListner class into it, that's these commands will not perform any action.

 

 

 

 

 

Our command class Midlet will look like as follow..

J2ME Command Class

Source Code of CommandMIDlet.java

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

public class CommandMIDlet extends MIDlet{
  private Form form;
  private Display display;
  private Command screen, back, cancel, ok, help, stop, exit, item;  
  
  public CommandMIDlet(){
    screen = new Command("Screen", Command.SCREEN, 1);
    back = new Command("Back", Command.BACK, 2);
    cancel = new Command("Cancel", Command.CANCEL, 3);
    ok = new Command("Ok", Command.OK, 4);
    help = new Command("Help", Command.HELP, 5);
    stop = new Command("Stop", Command.STOP, 6);
    exit = new Command("Exit", Command.EXIT, 7);
    item = new Command("Item", Command.ITEM, 8);
  }

  public void startApp(){
    display = Display.getDisplay(this);
    Form form = new Form("Command Priority");
    form.addCommand(screen);
    form.addCommand(back);
    form.addCommand(cancel);
    form.addCommand(ok);
    form.addCommand(help);
    form.addCommand(stop);
    form.addCommand(exit);
    form.addCommand(item);
    display.setCurrent(form);
  }

  public void pauseApp(){}

  public void destroyApp(boolean destroy){
    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 
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.