Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 06:48, 1 August 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

MIDP's User Interface Hierarchy

From Wiki
Jump to: navigation, search

The series MIDP's User Interface Hierarchy explores the MIDP's 2.0 user interface architecture and how to use them. The MIDP 2.0 provides two packages regarding user interface: the javax.microedition.lcdui and packages. The former stands for liquid crystal display user interface (LCD UI) and the other can be used to build wireless games.

Article Metadata
Created: thiagobrunoms (09 Oct 2009)
Last edited: hamishwillee (01 Aug 2013)

Introduction: Displayable

The LCDUI is divided into two groups: the high level group and the low level group. For a better understanding, let's consider the following figure, which depicts the UI component hierarchy of the high and low level groups. First of all, we should have only one Display (javax.microedition.lcdui.Display) reference per MIDlet in order to get screen information and request to display UI components in the screen. Each MIDlet can have one or more Displayable (javax.microedition.lcdui.Displayable) components. Displayable components can be a high or a low level component.

Figure adapted from: Core J2ME Technology.

The high level group belongs to the Screen (javax.microedition.lcdui.Screen) subgroup, which extends the Displayable class:

public abstract class Screen extends Displayable { ...  }

The low level group belongs to the Canvas (javax.microedition.lcdui.Canvas) subgroup, which uses the Graphics (javax.microedition.lcdui.Graphics) component to draw customized UI elements.

public abstract class Canvas extends Displayable { ... }

The process of getting and setting Displayables is through the Display API, which provides the following methods described in table 1.


For instance, if we would like to show a Screen or Canvas-based UI, we should get a Display reference before setting it:

     Display d = Display.getDisplay(midletReference);

Event Handling - Command Components

For event handling, Displayable class has a set of Command (javax.microedition.lcdui.Command) objects in order to handle external actions, such as "Ok", "Pause" or "Back" commands (Command components will be discussed in part 6 of this series). So, if you create a Screen-based UI or a Canvas-based UI, you can set as many Command objects as you wish. The Displayable class has also a Ticker component. Ticker components can be used a scrolling ticker tape (Ticker components will be discussed in part 7 of this series).

public abstract class javax.microedition.lcdui.Displayable {
javax.microedition.lcdui.Command[] commands;
javax.microedition.lcdui.Ticker ticker;

Screens and Item Components

Going down through the MIDP's UI hierarchy, we can have 4 Screen-based components: TextBox (discussed in part 2), List (discussed in part 3), Alert (discussed in part 4) and Form (discussed in part 5). These 4 components can apply a Ticker and as many Command objects as needed. In addition, the Form component can hold any number of Items, such as Date fields, Images, choice groups, etc, as we can see in the class definition below: (Item components will be discussed in part 5).

public class javax.microedition.lcdui.Form extends javax.microedition.lcdui.Screen {
private javax.microedition.lcdui.Item[] items;

The Item components can be added to a Form screen. All items extend the Item class. For instance, the following class definition is the TextField item.

public class javax.microedition.lcdui.TextField extends javax.microedition.lcdui.Item { ... }

Finally, this first part of this series only gives an overview of all MIDP's LCDUI components and it's hierarchy. The next part I will talk over about the first Screen-based component, called TextBox (MIDP's User Interface Hierarchy: TextBox).

This page was last modified on 1 August 2013, at 06:48.
34 page views in the last 30 days.