Share on Facebook Share on Twitter Email
Answers.com

MIDlet

 

A cellphone or pager application written in the Java 2 Platform, Micro Edition version (J2ME). See MIDP and J2ME.

Download Computer Desktop Encyclopedia to your iPhone/iTouch

Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
Wikipedia: MIDlet
Top

A MIDlet is a Java application framework for the Mobile Information Device Profile (MIDP) that is typically implemented on a Java-enabled cell phone or other embedded device or emulator. MIDlets are applications, such as games.

Mobile Information Device toolkit

MIDlet distributions main file is a .jar file, but MIDlet distributions can also consist of a .jad file containing the location of and describing the contents of the .jar file. The implementation of a MIDlet may or may not require the presence of a .jad file.

A MIDlet has to fulfill the following requirements in order to run on a mobile phone:

  • The main class needs to be a subclass of javax.microedition.midlet.MIDlet
  • The MIDlet needs to be packed inside a .jar file (e.g. by using the jar-tool)
  • The .jar file needs to be pre-verified by using a preverifier.
  • In some cases, the .jar file needs to be signed by the mobile phone's carrier.

Unlike a Java applet, a MIDlet is limited to use of the LCDUI rather than the more familiar widgets of AWT and Swing. There are many other aspects of the MIDP platform that MIDlet programmers must take into account.

Example

import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
 
public class CalendarControl extends MIDlet implements CommandListener {
   private Display display;
   private Display display2;
   private TextField userName;
   private TextField password;
   private Form form;
   private Form form2;
   private Command cancel;
   private Command login;
   private Command next;
   private ChoiceGroup technology;
 
 
   public CalendarControl() {
      userName = new TextField("LoginID:", "", 10, TextField.ANY);
      password = new TextField("Password:", "", 10, TextField.PASSWORD);
      form = new Form("Sign in");
      form2 = new Form("App Form");
      cancel = new Command("Cancel", Command.CANCEL, 2);
      login = new Command("Login", Command.OK, 2);
      next =new Command("Next", Command.OK,2);
      technology = new ChoiceGroup("Select Technology Which You Know", Choice.MULTIPLE);
   }
 
   public void startApp() {
      display = Display.getDisplay(this);
      form.append(userName);
      form.append(password);
      form.addCommand(cancel);
      form.addCommand(login);
      form.setCommandListener(this);
      display.setCurrent(form);
   }
 
   public void pauseApp() {
   }
 
   public void destroyApp(boolean unconditional) {
      notifyDestroyed();
   }
 
   public void validateUser(String name, String password) {
     if (name.equals("qm") && password.equals("j2")) {
       menu();
     } else {
       tryAgain();
     }
   }
 
   public void menu() {
    display = Display.getDisplay(this);
    technology.append("JAVA", null);
    technology.append("J2ME", null);
    technology.append("J2EE", null);
    technology.append("JSF", null);
    form2.addCommand(next);
    form2.append(technology);
    display.setCurrent(form2);
   }
 
   public void showMenu(){
 
   }
 
   public void tryAgain() {
     Alert error = new Alert("Login Incorrect", "Please try again", null, AlertType.ERROR);
     error.setTimeout(Alert.FOREVER);
     userName.setString("");
     password.setString("");
     display.setCurrent(error, form);
   }
 
   public void commandAction(Command c, Displayable d) {
      String label = c.getLabel();
      if(label.equals("Cancel")) {
        destroyApp(true);
      } else if(label.equals("Login")) {
         validateUser(userName.getString(), password.getString());
      } 
 
   }
}

See also

  • GetJar, the largest site for distribution of MIDlets.

 
 
Learn More
applet (technology)
J2ME (technology)
Mobile BASIC

How do you run midlet program? Read answer...

Help us answer these
How could you add background image to J2ME midlet form?
Can i use more than one MIDlet in a project?
How can you get java midlet application to your nokia phone?

Post a question - any question - to the WikiAnswers community:

 

Copyrights:

Computer Desktop Encyclopedia. THIS DEFINITION IS FOR PERSONAL USE ONLY.
All other reproduction is strictly prohibited without permission from the publisher.
© 1981-2010 The Computer Language Company Inc.  All rights reserved.  Read more
Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "MIDlet" Read more