Java Reference
In-Depth Information
of
Displayable
. If you think of
Display
as an easel, a
Displayable
instance is akin to a canvas on
that easel.
MIDlets can change the contents of the display by passing
Displayable
instances to
Display
's
setCurrent()
method. This is the basic function of a typical MIDlet:
Show a
Displayable
.
1.
2.
Wait for input.
3.
Decide what
Displayable
should be next.
4.
Repeat.
Displayable
has a small family of subclasses that represent various types of user interfaces.
Figure 5-1 shows the lineage.
Figure 5-1.
Displayables in the javax.microedition.lcdui and javax.microedition.lcdui.game package
Displayable
's progeny are split between two branches that correspond to the two methods for
creating generalized user interfaces, abstraction and discovery. The
Screen
class represents
displays that are specified in abstract terms.
These screens contain standard user interface items like combo boxes, lists, menus, and
buttons. Four subclasses provide a wide range of functionality, as illustrated in Figure 5-2.
The remainder of this chapter is devoted to explaining the simplest of these four classes:
TextBox
and
Alert
. The next chapter explores the more flexible
List
and
Form
.
For particularly demanding or idiosyncratic displays, you'll have to create a subclass of
Canvas
. Your MIDlet will assume responsibility for most of the drawing, but you get much finer
control over what is shown and how user input is handled.
Canvas
supplies methods that allow
your MIDlet to learn about its environment—the size of the display, for example, and which
kinds of events are supported by the device. User interfaces built on
Canvas
discover the attributes
of a device and attempt to create something that looks reasonable. Chapter 13 explains
Canvas
-
based user interfaces in detail.
GameCanvas
provides user interface functionality specifically for
game displays. This API is explained in Chapter 14.
Search WWH ::
Custom Search