- The design of a user interface for a MIDlet depends on the restrictions of a small computing device.
- Some small computing devices contain resources that provide a rich user interface, while other more resource-constrained devices offer a modest user interface.
- A rich user interface contains the following elements, and a device with a minimal user interface has some subset of these elements as determined by the profile used for the device.
- The Screen class contains a subclass called the Item class, which has its own sub classes used to display information or collect information from a user (such as forms, check boxes, radio buttons).
- The Screen class and its derived classes are referred to as high-level user interface components
- The Canvas class is used to display graphical images such as those used for games.
- Displays created using the Canvas class are considered a low-level user interface and are used whenever you need to display a customized screen.
Form Based UI
- A Form is the most commonly invoked user interface element found in a MIDlet and is used to contain other user interface elements such as List, ChoiceGroup, and Ticker.
- Static Text (label) is placed on a form as a StringItem.
Item Class:
- Instances of derived classes of the Item class are not directly displayable and must be contained within an instance of a Form class.
- An instance of an Item class appears on the screen when the setCurrent() method is used to show the form.
- The getCurrent() method of the Display class is used by a MIDlet to retrieve information about the instances of derivatives of the Displayable class.
- A StringItem contains text that appears on a form that cannot be changed by the user.
- A List is an itemized options list from which the user can choose an option.
- A ChoiceGroup is a related itemized options list.
- A Ticker is text that is scrollable.
- The Choice element returns an option that the user selected.
- TextBox and TextField elements collect textual information from a user and enable the user to edit information that appears in these user interface elements.
- The DateField is similar to a TextBox and TextField except its contents are a date and time.
- An Alert is a special Form that is used to alert the user that an error has occurred. An Alert is usually limited to a StringItem user interface element that defines the nature of the error to the user.
Event Processing
A MIDlet is an event-based application. All routines executed in the MIDlet are invoked in response to an event reported to the MIDlet by the application manager.
Load Event:
The initial event that occurs is load event, which takes place when the MIDlet is started. In response to this event, the application manager invokes the startApp() method.
The startApp() method in a typical MIDlet contains a statement that performs the following:
- Displays a screen of data and
- Prompts the user to enter a selection from among one or more options.
The nature and number of options is MIDlet and screen dependent.
Event Handler:
A Command object is used to present a user with a selection of options to choose from when a screen is displayed. Each screen must have a CommandListener.
A CommandListener monitors user events with a screen and causes the appropriate code to execute based on the current event.