Home > Articles > Web Services > XML

  • Print
  • + Share This
Like this article? We recommend

Working with the Display Object and the Displayable Interface

The MIDP List class implements the Displayable interface. Let me take a moment to talk about the Display class and the Displayable interface and how these features relate to WTK emulation.

Within the WTK, a mobile device has only one Display object. Yet at a given instant any one of many classes that implement the Displayable interface can be rendered on the Display object. In other words, you can have many displayable objects (objects that implement the Displayable interface) in memory, but only one can be rendered and have the focus at any given time (see Figure 4).

Figure 4Figure 4 You use the Display object's setCurrent(Displayable nextDisplay) method to render on the mobile device's screen the "displayable" object that you want to show. Let's take a moment to discuss the Displayable interface.

The Displayable interface is a set of functions that facilitates the rendering of text and graphics on a mobile device's display. The base class in the WTK that implements the Displayable interface is javax.microedition.lcdui.Screen. Four classes inherit from the Screen class:

  • The Alert class displays a message for a set period or until the user takes some action in response to a screen prompt.

  • The Form class is a combination of text boxes, lists, and graphics.

  • The List class displays a list from which the user selects.

  • The TextBox class displays an input box, into which the user can enter data using the mobile device's keypad.

Implicitly, all the classes shown above support the Displayable interface. Thus, I use the List class to show a list of tunes on the cell phone's screen. I render the List class on the mobile device's screen with a call to setCurrent(), as shown in the following code, where theList is an instance of a MIDP List object:

  • + Share This
  • 🔖 Save To Your Account