Java Reference
In-Depth Information
repaint();
}
}
public class BufferedStopWatch extends MIDlet {
public void startApp() {
Display display = Display.getDisplay (this);
display.setCurrent (new BufferedStopWatchCanvas (display,
10));
}
public void pauseApp() {
}
public void destroyApp (boolean forced) {
}
}
MIDP 2.0 Additions
Version 2.0 of MIDP improves the existing high-level user interface API significantly. Additionally,
there are three new packages packages,
javax.microedition.lcdui.game
,
javax.microedition.media
, and
javax.microedition.media.control
, especially
for game and multimedia programming.
LCDUI High-Level Improvements
For the high-level part of LCDUI, there are several significant additions and improvements:
• The new Class
CustomItem
allows user drawn items
•
Command
s can also be assigned to
Item
s
• All items have a new
setLayout()
method
The
CustomItem
class allows you to combine the flexibility of the low-level API directly with the
high-level API on the same screen. The ability to assign commands to items allows context-sensitive
menus, depending on the current focus position. For example, this could be used for nested option
dialogs or to build a hypertext browser based on the high-level API only. The
setLayout()
method
gives MIDP 2.0 applications better control over the actual layout of the items contained in a form.
The Game Package
The new game package contains graphical objects specially designed for games and animations. The
class
Sprite
is designed for adding active objects to games. Sprites can consist of a single image or a
sequence of images representing an animated sprite. In contrast to plain images, sprites have status
information such as the current position and animation frame. The
Sprite
class also contains
methods for detecting collisions with other sprites.
In addition to the
Sprite
, the game package contains another graphical object, the
TiledLayer
class. Tiled layers are large images constructed from equally sized cells and can be used for
implementing a scrolling screen background, for example. The cells are obtained from a single image
that is divided into a number of rows and columns, as defined by the
TiledLayer
constructor. Each
cell contains an index that points to a tile obtained from the image given to the constructor. When the
TiledLayer
is displayed on the screen, the cells are rendered from the tile corresponding to the
Search WWH ::
Custom Search