I. MIDLET Graphics 1, MIDlet Graphics Brief Report Mobile Information Device Description Defines an Application Programming Interface (API) to run MIDlet applications in the MIDP container. This set of APIs itself is based on the Connected Limited Device Configuration, CLDC application programming interface. The MIDP user interface application programming interface class is not based on the Java Abstract Window Toolkit, AWT. They are designed for small mobile information devices such as mobile phones and envelopes, and such devices are characterized by only small screens and keyboards. When a programmer is writing the MIDP graphics application, he may only use the MIDP or CLDC application programming interface. Align = "Right" marginwidth = "0" marginheight = "0" src = "http://www.chinabyte.com/tag/cont_flash_software.html" frameborder = "0" width = "360" scrolling = "no" height = "300"> The center of MIDP is an abstraction of the screen. The meaning of this sentence is the screen-based user interface design. That is, the Screen class encapsulates the device-specific graphics and user interactions, all user interface components are on the screen and only one screen is displayed at a time, and can only browse or use the entries on this screen. All user interface events are processed by the screen. And only send advanced events to your application. The reason why this screen-oriented, mainly because the display screen of mobile devices and the keyboard are too much type, and almost every manufacturer is small. 1 is some examples of the screen-based MIDP graphical user interface. Figure 1: Screen-based MIDP Graphical User Interface MIDP Application Programming Interface has advanced user interface classes and low-level user interface classes. Advanced User Interface classes (such as Form, List, TextBox, TextField, Alert, and Ticker) can be adapted to the device: support image, text, text input field, radio button, etc. Low-level user interface classes (CANVAS classes) allow developers to draw arbitrary graphics as needed. MIDlet can run on a variety of different sizes of colors, different grades or black and white screens. Advanced User Interface Class is an abstraction of a general user interface element, which is to improve the portability of MIDLET across different devices and can use the appearance of the local equipment. Low-level application programming interfaces can control display content more directly, but the MIDlet designer should ensure that it is portable in different devices (display size, keyboard, color, etc.). The above example is used in both the advanced application programming interface and the low-level application programming interface. All MIDP graphical user interface classes are part of the javax.microedition.lcdui package.
2, MIDlet screen MIDP has two main screen types: A Advanced Screen It includes a simple advanced screen class, such as List and TextBox. Users cannot add additional graphical user interface components to this type of screen. The screen used by the Nine-Town Midlet sample program is inherited to the list class named choosepiecescreen, which is used to select a chess piece when the player starts at the start of the game. The general FORM screen class and the List class are very similar, but it allows additional graphic elements, such as images, read-only text domains, editable text domains, editable data fields, ruler, and option groups. The Form entry can be arbitrarily added or deleted. There is no FORM class in the Jiuguan Rig. B Level Screen Canvas screen (and Graphics, Image classes) can be used to write a user interface based on the low-level application programming interface. These classes give MIDLET programmers to a large extent of painting flexibility. Programmers can draw various types of graphical elements, such as lines, arcs, rectangles, rounded rectangles, circles, text (different colors, fonts, sizes), bitmap clips, etc. Most game MIDlets are written using the main graphical user interface elements based on the canvas screen class. A MIDLET user interface typically contains one or more screens. Because only one screen can be displayed each time, the MIDlet has a well-designed structure that is very important, so it can handover the contents between the screens between the screens. The following code segment illustrates the method of switching the screen in a MIDLET, based on the screen class and the corresponding MIDlet callback. Snippet 1: Class MyMIDlet extends MIDlet {private FirstScreen firstScreen; private SecondScreen secondScreen; public MyMIDlet () {...} public void startApp () {Displayable current = Display.getDisplay (this) .getCurrent (); if (current == null ) {firstscreen = new firstscreen (this, ...); display.getdisplay (this) .SetCurrent (firstScreen); // Displays the first user interface screen of the application} else {Display.getDisplay (this) .SetCurrent (current) ;}} // FirstScreen callback to the next screen public void firstScreenDone () {... secondScreen = new secondScreen (this, ...); display.getDisplay (this) .setCurrent (secondScreen);} // secondScreen public terminate the application callback Void secondscreenquit () {... destroyApp (false); notifyDestroyed ();} ...}
This MIDlet uses two screen classes (FirstScreen and Secondscreen as the user interface. When you start executing MIDlet, it sets the current display screen for Firstscreen. When you need to switch from Firstscreen to Secondscreen, FirstScreen calls the parent MIDlet method firstScReendone (see the code below). The firstScreenDone method creates and sets SecondScreen as the current displayed screen.
Code segment 2: FirstScreen example containing MIDlet callbacks
Class FirstScreen extends Form implements CommandListener {private MyMIDlet midlet; public FirstScreen (MyMIDlet midlet) {this.midlet = midlet; ...} public void commandAction (Command c) {if (c == cmdQuit) {parent.firstScreenDone ();} ... } ...} 3, MIDP User Interface Application Programming Interface
Ensure that the portability and applicability of user interface objects based on advanced application programming interface classes are the responsibility of the MIDP device.
On the other hand, low-level classes such as Canvas and Graphics provide a larger free space to control their user interface visual performance, and listen to the low-level keyboard events. The programmer is also responsible for ensuring portability on mobile devices in different features such as display size, color or black and white, and different keyboard types. For example, it is possible to use the getWidth () and getHeight () methods to adjust the user interface to adapt to one or more devices available canvas size.
The following nine-rich MIDlet routine will be introduced:
Simple application advanced application programming interface;
Use the low-level application programming interface to draw graphics such as lines, arcs, strings, and images;
MIDlet transplantation between mobile devices of different display sizes
Map between keyboard code and game action
This chapter outlines the design of the MIDP graphical user interface. If you want to get further information, see
http://java.sun.com/products/midp/.