During the development of mobile phones, it will definitely involve problems in graphics processing. Like transaction processing, MIDP processes graphical interface
Also divided into advanced graphical interface processing and low graphical interface processing. Similarly, the advanced graphical interface processing method can be convenient, but
The function is limited, the low graphical interface is powerful, but the partial code may be required after the removal value will be required. Advanced graphics interfaces need to be inherited
Screen, while the low-level graphical interface is inherited to Canvas, and a large number of graphics processing defined by Graphics. Graphics used by MIDP
The interface class belongs to the javax.microedition.lcdui used in the front code. At the same time (only the same
Time) The subclass of Canvas and Scree can only exist. There are four subclasses in the Screen class, Alert, List, TextBox, Form. Where Form is an element that does not have any interface.
It is just a container that can accommodate other Item classes in which a complex graphics used interface is used. And several other subclasses belong to
The predetermined fixed graphics interface package can only be used separately. This is actually related to the relationship between various input boxes and FORM inside HTML
same. Oh, as before learning other development languages, one by one to test various methods of use of these subclasses. ^ _ ^ With actual first prior
Description of the relationship between the relationship and the difference. First, List 1) Choice.Implicit
Package com.graph;
/ ** * @AuThor you li * * Copyright (c) 2005 * / import javax.microedition.lcdui. *; Import javax.microedition.midlet. *;
Public Class ImplistTest Extends MIDlet ImmandListener {
PRIVATE DISPLAY; PUBLIC IMPLISTTEST () {// TODO Automatically generates constructor stub Display = display.getdisplay (this);}
Protected Void Startapp () throws MidletStateChangeException {// TODO Automatic Generation Method Store List Alist = New List ("Listtest", choice.implicit; alist.Append ("a", null); alist.append ("b", null ); Alist.append ("c", null; alist.append ("d", null); alist.setcommandlistener (this); display.setcurrent (alist);}
Protected void pauseapp () {// TODO automatic generation method stub
}
Protected Void DestroyApp (Boolean Arg0) THROWS MIDLETSTATECHANGEEXCEPTION {// TODO automatic generation method stub
}
Public void command (Command Command, Displayable Display) {// TODO Automatic Generation Method Store System.out.Println ("Command Action Start ..."); if (Command == List.Select_Command) {List test = (List) Display; int class = Test.getSelected Indindex (); system.out.println ("item" selected "selected");}}}
When we run this program, you will find four options on the screen, and promise the indexid of the selected option, so it can be seen
Options to Choice.Implicit are selected, it will use the setcommandlistener () method immediately, and call COMMA at the same time
DNAction () method. At the same time, it is judged whether or not the choice.imumit option is used by the first parameter of the COMMMADNACTION () method.
2) Choice.exClusive
Package com.graph;
/ ** * @AuThor you li * * Copyright (c) 2005 * / import javax.microedition.midlet. *; Import javax.microedition.lcdui. *;
Public Class ExclistTest Extends Midlet ImmmandListener {
PRIVATE DISPLAY; commnd commission; public exclistte () {// TODO automatically generates constructor stub Display = display.getdisplay (this);}
protected void startApp () throws MIDletStateChangeException {// TODO method of automatically generating stubs commit = new Command ( "Submit", Command.SCREEN, 1); List alist = new List ( "ListTest", Choice.EXCLUSIVE); alist.append ( "A", null; alist.append ("b", null); alist.append ("c", null); alist.addcommand (commit); alist.setcommandlistener (this); Display.setCurrent (alist); }
Protected void pauseapp () {// TODO automatic generation method stub
}
Protected Void DestroyApp (Boolean Arg0) THROWS MIDLETSTATECHANGEEXCEPTION {// TODO automatic generation method stub
}
Public void command (Command Command, Displayable Display) {// TODO Automatic Generation Method Store System.out.Println ("Commmadn Action Start ..."); if (Command == Commit) {List TMP = (List DISPLAY; int class = tmp.getSelectedIndex (); system.out.println ("Item" SELECTED "SELECTED");}}} We will find the difference between choice.exclusive and choice.exclusive and choice.implicit. . Choice.exClusive is not
Will run the CommandAction () method immediately after we choose, we can only complete the final submission.
When we click on the commistrative commistrative commit, you will execute the commandAction () method.
3), choice.multiple
/ ** * @AuThor you li * * Copyright (c) 2005 * / import javax.microedition.midlet. *; Import javax.microedition.lcdui. *;
Public Class MultlistTest Extends MIDlet ImmandListener {
PRIVATE DISPLAY; Command Commital; Public MultlistTest () {Display = Display.getDisplay;}
Protected Void Startapp () THROWS MIDLETSTATECHANGEEXCEPTION {// TODO Automatic Method Store Commit = New Command ("Submit", Command.Screen, 1); List Alist = New List ("ListTest", choice.multiple; alist.Append "A", null; alist.append ("b", null); alist.append ("c", null); alist.addcommand (commit); alist.setcommandlistener (this); Display.setCurrent (alist); }
Protected void pauseapp () {// TODO automatic generation method stub
}
Protected Void DestroyApp (Boolean Arg0) THROWS MIDLETSTATECHANGEEXCEPTION {// TODO automatic generation method stub
}
Public void command (Command Command, Displayable Display) {// TODO Automatic Generation Method Store System.out.Println ("Commmadn Action Start ..."); if (Command == Commit) {List TMP = (List ) Display; int Num = tmp.size (); for (int i = 0; i In this program we used choice.multiple, that is, the use of multiple options. Like choice.exclusive, only when The CommandAction () method is called after using the system menu Commital to operate. Second, Alert and AlertType Windows, there is also a dialog box on the general page, this Alert is actually this role. It belongs to the subclass of SCREEN, We can use the Display Tired setCurrent () method to display it on the screen, of course, when the Alert is set to feed the screen screen It must have a picture, otherwise Alert can't jump, will throw an error. If we feed a Alert object, set it Aler TTYPE's properties AlertType.Alarm, then then we need to click the system confirmation button will return from the Alert window. Start window. A simple example is as follows: Only when the "window" is displayed, the AlertType.Alarm is set, so you need to click "DONE" to The Alert object will be turned off. Package com.graph; / ** * @AuThor you li * * Copyright (c) 2005 www.iguess.com.cn * / import javax.microedition.midlet. *; Import javax.microedition.lcdui. *; Public Class AlertTest Extends MIDlet ImmandListener { PRIVATE DISPLAY; command commit; public alertTest () {Display = display.getdisplay (this);} Protected Void Startapp () Throws MidletStateChangeException {// TODO Automatic Generation Method Store List Alist = New List ("ListTest", choice.implicit; alist.Append ("Window", NULL); Alist.Append ("confirm", NULL ); Alist.Append ("error", null; alist.append ("information", null); alist.append ("warning", null; alist.setcommandlistener (this); display.setcurrent (alist);} Protected void pauseapp () {// TODO automatic generation method stub } protected void destroyApp (boolean arg0) throws MIDletStateChangeException {// TODO method of automatically generating stubs} public void commandAction (Command command, Displayable dis) {if (command == List.SELECT_COMMAND) {Alert alert = new Alert ( "test window") List temp = (list) Dis; switch (Temp.getSelectedIndex ()) {case 0: alert.settype (AlertType.Alarm); Alert.SetString ("Window"); Alert.SetTimeout; Display. SetCurrent (Alert); Break; Case 1: Alert.SetType (AlertType.confirmation); Alert.setString; Display.SetCurrent (Alert); Break; Case 2: alert.Settype (AlertType.Error); Alert; Alert .setString; Display.SetCurrent (Alert); Break; Case 3: alert.settype (AlertType.info); Alert.setString ("Information"); Display.setCurrent (Alert); Break; Case 4: Alert.Settype (AlertType.warning); Alert.setString ("Warning"); Display.SetCurrent (Alert); Break;}}}} 11:30. . . I am going to watch TV on time. . Oh, from 8:00 in the morning, I have been in front of the computer. surface. . I feel that my eyes are hurt. . Ugh. . . Work is done to the boss, and the money earns to the country, but it is the body is itself. . programmer. . TMD is still born. . . . Take a break. . Learning is not finished. . .