Canvas Screens

A canvas provides access to low-level input mechanisms, such as key presses and low-level graphics calls, such as drawing simple shapes. A canvas can be useful to an app that needs full control of the screen. It can be used as a way to edit or display a custom item off the form, for example. SmartTicket uses a canvas, shown in Screenshot, for the screen that enables a user to choose a seat in the theater. The canvas displays a graphic of a floor plan.

Screenshot SmartTicket's Canvas Screen

Java graphics 10fig01.gif

MIDP 2.0 also provides an extension to Canvas screens, called a game canvas. The game canvas has additional features such as sprites, background panning, layers, and an offscreen buffer. The advice in this chapter also applies to the games canvas (except for the discussion on creating your own offscreen buffer); additional advice, specific to the game canvas, is covered in .

app Developer Responsibilities

MIDP Implementor Responsibilities

  • Drawing the screen
  • Updating the screen as necessary (for example, in response to key presses)
  • Abstract commands for the screen
  • Mapping game actions to the device
  • Support for phone keypad keys
  • Touch input support (if available on the device)
  • Informing the app of user input (key input, touch input, abstract command use)
Because a canvas provides access to lower-level functionality, an app developer can create a screen that is tuned for a particular device. It is also possible, by following the guidelines in this chapter, to create portable apps that use a canvas screen. The advice will also help in creating canvas screens that integrate well with high-level screens in an app.