Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Device programming with MIDP, Part 2

Use these user-interface and data-store components to create MIDP-based applications

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Part 1 of this series was focused on the deployment of the J2MEWTK environment and a rudimentary exploration of the MIDP APIs. This part of the series will focus on the development of an application using the pre-canned user interface components provided in the MIDP API. In addition, I'll explore the conversion and storage of application data to the MIDlet RecordStore. These two concepts will be discussed in detail through a simple Stock Portfolio management application constructed specifically for this article.

TEXTBOX: TEXTBOX_HEAD: Device programming with MIDP: Read the whole series!

The hierarchy of Displayable objects

In the examples found in Part 1, I discussed the two major categories of Displayables: Canvas and Screen.

Canvasis a type of Displayable in which the developer accepts responsibility for creating the entire user interface. This is an extremely useful interface for creating complex graphical interfaces, such as those used in video games. If you choose this path, the UI is drawn on a Canvas object similar to the AWT Canvas used in applets.

Screenis a type of Displayable in which you use predefined components to assemble a user interface. The components are similar to those AWT components used in constructing applets, such as Label and TextField. If you choose this path, you will need to add components to a subclass of the abstract Screen object when necessary to construct your user interface.

I will focus on the Screen type of Displayableobject in this part of the series, since the Canvas object was sufficiently discussed Part 1. As I mentioned above, the Screen object is an abstract class of Displayable. The subclasses of the Screenclass are Alert, Form, List, and TextBox.

In this article, I will examine the mechanics of these Displayableobjects, including the construction, interaction, and event-handling schemes that enable them to come together to form an application.

Detailed example

The best way to learn how to use some of these screens is through an example. The example used here contains some workflow that demonstrates the following concepts:

  • Construction with different screen types
  • Construction with different screen components
  • Usage of commands from within the javax.microedition.lcduiclasses
  • An implementation of MVC for efficient screen manipulation
  • Interaction with the javax.microedition.rms data store on the device


To provide this information, I will use a simple rendition of a brokerage application. In this application, the user can buy a stock or sell a stock that he or she currently owns. Please understand that this process has been highly simplified in order to demonstrate key concepts.

In Part 3 of this series, I will expand this application to connect with a ticker service to retrieve accurate pricing for the purchase-using HTTP.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (3)
Login
Forgot your account info?

helloBy Anonymous on June 7, 2010, 2:27 amhello

Reply | Read entire comment

helloBy Anonymous on June 7, 2010, 2:27 amhello

Reply | Read entire comment

helloBy Anonymous on June 7, 2010, 2:25 amhello

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources
  • Other JavaWorld articles by Michael Cymerman: