»  Home
»  Getting Started
»  J2ME UI
   »  UI Architecture
   »  High Level UI
   »  Handling Commands
   »  Low Level UI
   »  Further Reading
»  LBS
»  Appendix

Username

Password





High Level UI




We will go through the high level API briefly. Remember, it is not comprehensive. You need to follow the API documentation to know about all the features. That is easy once you have got a taste of it.


Alert

  • They are used to convey a short message to the user.
  • Alerts can be of five types INFO, WARNING, ERROR, ALARM, and CONFIRMATION corresponding to its purpose. A sound can be played according to the type of alert, the sound dependent on the device.
  • A title must be passed to the Alert constructor e.g. Alert("Title"), which can't be changed subsequently. Another constructor is also there which takes more arguments in addition to the title.
  • The message is set as setString("Message to display").
  • The time for which an alert is shown is determined by setTimeout(int time) where 'time' is in milliseconds. It can be set as Alert.FOREVER to keep it displayed till the user dismisses it. I suggest that you set it to FOREVER or a high value during development so that you don't miss it, during actual deployment the time out might be set less.
  • An image may be attached to the alert using setImage(Image image).

Check the program AlertDemo.java

List

  • It is used when a user need to select one or multiple elements from an available set of options
  • It can be of three types Choice.EXCLUSIVE (only one element can be selected) Choice.MULTIPLE (multiple elements can be selected), or Choice.IMPLICIT (the currently highlighted element is selected). Change the list type in the given example and see how the look and functioning alter.
  • Each option (basically a String) in a List can have an image associated with it.
  • A list can either be created blank and choices can be appended to it or a set of choices can be constructed first and a List can be created with that set.
    List (String title, int listType)

    List (String title, int listType, String [] stringElements, Image [] imageElements)
Check the program ListDemo.java

Textbox

  • A textbox lets a user input text.
  • It has six constraint settings for restricting content: ANY, EMAILADDR, NUMERIC, PHONENUMBER, URL, and DECIMAL. ANY allows all kinds of text to be entered, while the rest constrain according to their names.
  • Similarly, there are six constraint settings that affect the display. These are: PASSWORD, UNEDITABLE, SENSITIVE, NON_PREDICTIVE, INITIAL_CAPS_WORD, and INITIAL_CAPS_SENTENCE.
  • Not all of these settings may be functional in all devices.

  • If you want a combination just do OR operation on the two Constraints.
  • If you want a user to input a 4-digit PIN number, construct the text box as
    pinInput = new TextBox("Input PIN", "", 4, TextField.NUMERIC | TextField.PASSWORD);

Form

  • It contains a collection of items. You can set and place the times according to your need inside a form.
  • StringItem - Used to place a String not modifiable by the user. Form also provides a shortcut append(String stringItem) to append strings.
  • DateField - Used to add date and time info.
  • TextField - similar to TextBox.

  • ChoiceGroup - similar to List.
  • Spacer - Empty element to provide space between other elements, used to control placement of elements in UI design.
  • Gauge - It can either be used to denote progress in a process e.g. downloading a file or it can be an interactive element e.g. a volume control.
  • ImageItem - Used to display image. A shortcut to add image to Form is append(Image imageItem).
  • CustomItem - It is an abstract class, which you can extend to design your own element with its own look, interactivity etc.
Check the program FormDemo.java

Before we move on, few points to note -


  • Dismissing an Alert automatically brings back previous screen. When an alert disappears (either expiring the timeout limit or manually by the user), the previous displayed object is automatically set visible.
  • A change in a displayable unit is displayed instantaneously if it's visible. Say a list was being displayed with 3 options and the program adds a fourth option, it is made visible to the user immediately, no need to 'refresh' manually.


Use the menu at top-left corner for navigation.


Created on 01/21/2007 12:24 AM by admin
Updated on 02/16/2007 06:35 AM by admin
 Printable Version

The comments are owned by the poster. We are not responsible for its content.