a displayable object within the application using the addCommand()
ItemCommandListener is a listener type for receiving notification
of commands that have been invoked on Item objects. This provides
the mechanism for associating commands with specific Form items,
thus contextualizing user input and actions according to the current
active item on the form, making it more intuitive.
ItemStateListener is used by applications that need to receive
events that indicate changes in the internal state of the interactive items
within a form; for example, a notification is sent to the application
when the set of selected values within a ChoiceGroup changes.
2.3.4 LCDUI Low-Level API: Canvas
The low-level API allows developers to have total control of how the
user interface looks and how components are rendered on the screen.
Canvas , the main base class for low-level UI programming, is used
to exercise such fine-grained control. An application should subclass
Canvas to create a new displayable screen object. As it is displayable,
it can be used as the current display for an application just like the
high-level components. Therefore a MIDlet application can have a user
interface with, for example, List , Form and Canvas objects, which can
be displayed one at a time to provide the application functionality to the
Canvas is commonly used by game developers when creating sprite
animation and it also forms the basis of GameCanvas , which is part
of the Game API (see Section 2.3.6). Canvas can be used in normal
mode, which allows title and softkey labels to be displayed, and full-
screen mode, where Canvas takes up as much of the display as the
implementation allows. In either mode, the dimensions of the Canvas
can be accessed using the getWidth() and getHeight() methods.
Graphics are drawn to the screen by implementing code in the abstract
paint() method. This method must be present in the subclass and
is called as part of the event model. The event model provides a
series of user-input methods such as keyPressed() and pointer-
Pressed() , depending upon the device's data input implementation.
The paint(Graphics g) method passes in a Graphics object, which
is used to draw to the display.
The Graphics object provides a simple 2D, geometric-rendering
capability, which can be used to draw strings, characters, images, shapes,
etc. For more details, please check the MIDP documentation.
Such methods as keyPressed() and pointerPressed() repre-
sent the interface methods for the CommandListener . When a key is
pressed, it returns a key code to the command listener. These key codes are