Developing a user interactive application is a daunting task. A developer needs to be very careful and understanding while developing an application that supports a user interface. He should very intelligently use colors in the application, so that it does not pinch in the eyes of users or appear as overdone. He should be careful while using the user interface components such as text box, check box, etc. For example, if only one of the two options must be selected then instead of using check box, radio buttons should be used.
The profile provides user interface in a mobile application. The CLDC based applications use MIDP, i.e., the Mobile Information Device Profile for providing user interface in the application.
The
The high-level user interface class hierarchy is depicted by the following image:

The Displayable class is the base class of all user interface classes. The direct subclasses of the Displayable class are Screen and Canvas.
The
The
- Form
- List
- Alert
- TextBox
Each of these subclasses is discussed below in detail:
The Form class is like a placeholder. It covers the entire displayable screen area on the device.
The code below creates a form with a label:
import javax.microedition.lcdui.*;
public class Tree extends MIDlet {
public StringItem s1;
private Form a; // Form variable
display=Display.getDisplay(this);
public void startApp(){
display.setCurrent(a);
public void pauseApp() {
}
public void destroyApp(boolean b) {
}
}
The following items can be placed on a Form:
- ChoiceGroup
- Gauge
- Ticker
- TextField
- StringItem
Each item is discussed below in detail:
The ChoiceGroup class is used to create check boxes and radio buttons. An instance of the ChoiceGroup class can either be exclusive or multiple. The exclusive instance is for radio buttons, and the multiple is for check boxes. The ChoiceGroup instance is created with the following syntax:
Here, the label parameter specifies the caption for the check boxes.
The choicetype parameter specifies one of the following three constants:
- EXCLUSIVE: It allows a user to choose only one option.
- MULTIPLE: It allows a user to choose more than one option.
- POPUP: It allows a user to select one item at a time.
The figure below shows a ChoiceGroup with MULTIPLE constant type:

The figure below shows a ChoiceGroup with POPUP constant type:

The Gauge class is a subclass of the Item class. It defines methods to create animated progress bar. This progress bar graphically depicts the status of a process. The following syntax is used to create an instance of the Gauge class:
Here, the Label parameter defines the caption displayed on the screen with the gauge.
The Val parameter defines whether or not the gauge is interactive. A boolean true indicates that the gauge is interactive, and a boolean false indicates that the gauge is non interactive.
The Max parameter defines the maximum value of the gauge.
The Min parameter defines the minimum value of the gauge.
The image below depicts a non-interactive Gauge:

Ticker is a class used to display a message across the horizontal screen of the device. An instance of the Ticker class can be associated with any class derived from the Screen class. It has the following methods:
- Ticker(String str): It creates a new Ticker. The String parameter defines the string to be displayed.
- String getString(): It extracts the text displayed by the Ticker.
- void setString(String str): It defines the method to be displayed by the Ticker or replaces the string of an already created Ticker.
The TextField class is used to take single-line or multiple-line input from a user. The number of characters depends upon the maximum size of the TextField. The general syntax to create a TextField is as follows:
The label defines the visual text displayed before the text box.
The input is the text entered by a user.
The size defines the maximum number of characters the TextField can take as input.
The constraint defines the TextField constants. These constants are listed below:
- CONSTRAINT_MASK: It determines the constraint’s current value.
- ANY: It takes any character as input.
- EMAILADDR: It takes only a valid email address.
- NUMERIC: It takes both positive and negative numbers.
- PASSWORD: It hides the input while a user is entering data.
- PHONENUMBER: It takes only valid phone numbers.
- URL: It takes the valid address of a Web site.
StringItem is a high-level user interface component. It is used to display a string or pair of strings on a Form. A user cannot modify the value displayed by a StringItem. It defines the following constructor:
public StringItem(String Label, String Text)
Here, the Label parameter defines the caption to be displayed with the StringItem instance.
The Text parameter defines the string to be displayed with the StringItem instance.
import javax.microedition.lcdui.*;
public class Tree extends MIDlet {
public StringItem s1;
private Form a;
private Display display;
public Tree() {
display=Display.getDisplay(this);
a=new Form(”My”);
s1=new StringItem(”My”, “First Trip to Chicago”);
a.append(s1);
}
public void startApp(){
display.setCurrent(a);
}
public void pauseApp() {
}
public void destroyApp(boolean b) {
}
}
The image below depicts the StringItem created using the above code:

The append() or insert() method is used to associate a Displayable instance with an Item.
The List class is a subclass of the Screen class. Like any other subclass of the Screen class, it, too, covers the entire displayable area of the device. It provides user interface by displaying a list of items to a user. The user can select an item from the list. The general syntax for creating a List object is as follows:
List l=new List(java.lang.String title, int listType)
Here, the title parameter specifies the text to be displayed with an instance of the List class.
The listType parameter defines the type of list. It can be one of these types:
- EXCLUSIVE: It allows a user to select only one item at a time.
- IMPLICIT: It allows a user to select the currently focused item at the time of a command invocation.
- MULTIPLE: It allows a user to select more than one item at a time.
The Alert class covers the entire screen. It provides user interface. The main function of the Alert class is to inform a user about any errors or exceptions. It has the following two constructors:
- Title: It specifies the label or caption for an instance of the Alert class.
- Alert text: It displays an alert message.
- Alert type: It specifies an image to be displayed with the specified message. It is an optional parameter.
- A: It specifies one of the AlertType constants such as WARNING, INFO, etc.
The instance of the Alert class is made available to a user by passing it as an argument to the setCurrent() method.
The TextBox like any other subclass of the Screen class covers the entire screen of the device. It is used to take input from a user. It allows multi-line input. It has the following constructor:
The label parameter defines the caption displayed before the TextBox.
The text is the user’s input.
The size defines the number of acceptable characters in the TextBox.
The type parameter defines the kind of value accepted by the TextBox. It can be one of the following:
- CONSTRAINT_MASK: It determines the constraint’s current value.
- ANY: It takes any character as input.
- EMAILADDR: It takes only a valid email address.
- NUMERIC: It takes both positive and negative numbers.
- PASSWORD: It hides the input while a user is entering data.
- PHONENUMBER: It takes only valid phone numbers.
- URL: It takes the valid address of a Web site.
The Display class represents a logical device screen on which a MIDlet displays its user interface components such as Form, List, etc. Every MIDlet can access a single instance of the Display class using the
The high-level user interface display is simple to implement in an application. It does not allow developers to manipulate the appearance of the above-mentioned components on the screen, i.e., it does not provide a pixel-by-pixel control of the screen like low-level user interface.
Pass SCMAD in first attampt. Click here to get free CX310-110 SCMAD Mobile Application Developer exam practice questions.