Vous êtes sur la page 1sur 4


• 1 Overview
♦ 1.1 Introduction: Displayable
♦ 1.2 Event Handling -
Command Components
♦ 1.3 Screens and Item
• 2 Other Links

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
javax.microedition.lcdui.game packages. The former stands for liquid crystal display user interface (LCD UI)
and the other can be used to build wireless games.

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.

Overview 1

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.

Introduction: Displayable 2

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).

Event Handling - Command Components 3

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).

Other Links
• http://efforts.embedded.ufcg.edu.br/javame/

Other Links 4