Skip to Main Content
Wireless Java
book

Wireless Java

by Qusay H. Mahmoud
January 2002
Intermediate to advanced content levelIntermediate to advanced
264 pages
8h 3m
English
O'Reilly Media, Inc.
Content preview from Wireless Java

The High-Level MIDP APIs

Now, let’s see how the various classes in the high-level API can be used to create GUI components. We will cover two parts of this process: working with screens and the components that subclass them, and working with forms and the components that can be arranged in them.

Working with Screens

Having seen an example of a screen, a few questions immediately come to mind: how do you manage screens, how do you navigate through them, and how do you manage the display and the input devices? The answer is that all this functionality is implemented by the Display class, which includes methods for requesting that objects be displayed on the device, and for retrieving properties of the device.

Display

A reference to the device’s display can be obtained by providing a MIDlet reference to the static getDisplay( ) method.

public static Display getDisplay(MIDlet c);

This is typically done in the startApp( ) method of a MIDlet, as follows:

public class MyMIDlet extends MIDlet {

   Display display = null;

   public MyMIDlet(  ) { // constructor
   }

   public void startApp(  ) {
      display = Display.getDisplay(this);
   }

   // other methods
}

Tip

The getDisplay( ) method should be called after the beginning of the MIDlet’s startApp( ) method, as shown earlier. It should never be called from the MIDlet’s constructor, as per the MIDP specification, as it may not be properly initialized by the application manager at that time.

After you obtain a reference to the device’s display, you simply need to ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Wireless J2ME™ Platform Programming

Wireless J2ME™ Platform Programming

Vartan Piroumian
Java Power Tools

Java Power Tools

John Ferguson Smart

Publisher Resources

ISBN: 0596002432Supplemental ContentCatalog PageErrata