I bought it today.
2.5
lb
Coffee beans, Starbucks. A little more expensive, used 599 oceans, huh, oh, occasional luxury is not too much. Just grinding a cup of coffee, taking the smoke, huh, huh, continue J2ME learning course. Although I have seen it today, it is estimated that I can't see it today. I have to go to the company tomorrow, so I still have to rest early. . . Think about the first few weeks, soho is my work time every night, during the day. . Hey, sleep. . . It's really happiness. . . Good days are no longer. . .
Oh, TextBox, it seems to look at the name, know what is done, the input box inside HTML. Oh, I feel almost. Write one (with TextBox has the same way of use): Textfield, huh, huh, I feel this is the textarea inside HTML. ^ _ ^)
Test procedure first:
Package com.graph;
/ **
* @Author you li
*
* CopyRight (C) 2005 www.iguess.com.cn
* /
Import javax.microedition.midlet. *;
Import javax.microedition.lcdui. *;
Public Class TextBoxTest Extends Midlet ImmationListener {
Private display display;
Command commit;
Public textboxtest () {
Display = display.getdisplay (this);
// TODO automatically generates constructor stub
}
Protected void startapp () throws midletStateChangeException {
// TODO automatic generation method stub
Commit = New Command ("Submit", Command.Screen, 1);
TextBox TB = New TextBox ("Input Box", "Default", 12, TextField.Any);
tb.addcommand (commit);
Tb.setCommandListener (this);
Display.SetCurrent (TB);
}
protected void pauseapp () {
// TODO automatic generation method stub
}
Protected Void DestroyApp (Boolean Arg0) throws midletStateChangeException {
// TODO automatic generation method stub
}
Public void CommandAction (Command C, Displayable S) {
TextBox TMP = (TextBox) S;
System.out.println (tmp.getstring ());
}
}
The function of this program is to print the content entered on the screen in the background. TextBox ("Input Box", "Default", 12, TextField.Any, this is the properties used to set the dialog box. I tested today, I saw the document, mainly in the last two attributes, the number indicated the maximum number of characters that this input box can accept, TextField.Anddddr; TextField.EmailadDR- accept email address; textfield.Numeric- Only accept digital input; TextField.password- enter your password; TextField.phonenumber- Enter phone number, that is, you can accept numbers, spaces, asterisks, wells; TextField.url-accept the input URL; TextField.constraint_mask- used The result of the TEXTBOX's getConstraints () method is followed by AND logic, and then the current qualified setting can be obtained. Of course, this parameter should not be used when TextBox is created. Oh, TextBox is, I learned the easiest thing for these days, huh, huh, it seems that today is good, it may be the role of Starbucks. Ha ha. . . By the way, I'm trying to have a coffee, if I like to join the milk, I must be coffee into the milk, so the milk in the coffee is more embarrassing ^ _ ^ is also my habit, of course, I never put sugar, I think that Go back to the coffee. When you take a break, you will have a cup of now grinding coffee will let you feel the elegance of life, and you will make you temporarily stay away from the city's troubles. Coffee & smoke, a quiet weekend plus J2ME information, feeling good :)
Oh, it's far away = _ =!
Start Take a look at the from, like HTML, the Form alone has no meaning. It must contain subclasses with Item classes.
Write a Form test program:
Package com.graph;
Import javax.microedition.midlet. *;
Import javax.microedition.lcdui. *;
/ **
* @Author you li
*
* CopyRight (C) 2005 www.iguess.com.cn
* /
Public Class FormTest Extends Midlet Immancell, ItemStateListener {
Private display display;
Command commit;
Public formtest () {
Display = display.getdisplay (this);
// TODO automatically generates constructor stub
}
Protected void startapp () throws midletStateChangeException {
// TODO automatic generation method stub
Commit = New Command ("Commit", Command.screen, 1);
Form f = new form ("formtest");
F.Append ("string 1"); // is equivalent to New StringItem (Null, "String 1")
F.Append ("String 2");
F.Append (New StringItem ("Label 1", "Content 2")); F.Append (New StringItem ("Label 2", "Content 2");
f.addcommand (commit);
F.setCommandListener (this);
F.SetItemStatelistener (this);
Display.setcurrent (f);
}
protected void pauseapp () {
// TODO automatic generation method stub
}
Protected Void DestroyApp (Boolean Arg0) throws midletStateChangeException {
// TODO automatic generation method stub
}
Public void CommandAction (Command C, Displayable S) {
// TODO automatic generation method stub
FORM TMP = (form) S;
For (int i = 0; i StringItem Si = (StringItem) Tmp.get (i); // Get () method Remove the value of the ITEM class, so it is necessary to force the StringItem class. System.out.println (Si.getText ()); } } Public void itemStateChanged (item arg0) { // TODO automatic generation method stub } } Oh, although there is no comment, it is not a comment, but the entire StringItem itself is not very complicated. So there is no too much record. The use of ImageItem is basically the same as StringItem. Its constructor is: Append (New ImageItem, location control parameters, replacement text); ImageItem position parameter is mainly slightly below a few: ImageItem.LAYOUT_DEFAULT; ImageItem.LAYOUT_LEFT; ImageItem.LAYOUT_RIGHT; ImageItem.LAYOUT_CENTER; ImageItem.LAYOUT_NEWLINE_BEFORE; ImageItem.LAYOUT_NELINE_AFTER Its other constructor is append (new image ()); this is equivalent to calling the Append (NULL, Image Object, ImageItem.Layout_Default, Null) to construct the ImageItem object. ChoiceGroup, just like the List with ChoiceGroup, just use the List, because ChoiceGroup and List will build a choice selection box for us. Still first look at the program. Package com.graph; / ** * @Author you li * * CopyRight (C) 2005 www.iguess.com.cn * / Import javax.microedition.midlet. *; Import javax.microedition.lcdui. *; Public class choicegrouptest extends midlet imports itemptionelistener { Private display display; Public choicegrouptest () { Display = display.getdisplay (this); // TODO automatically generates constructor stub } Protected void startapp () throws midletStateChangeException { // TODO automatic generation method stub Form f = new form ("formtest"); Choicegroup cg = new choicegroup ("choiceGrouptest", choice.exclusive); // Build a choice parameter and List, except for Implicit, Exclusive, Implicit parameters can be used CG.Append ("a", null); Cg.Append ("b", null); Cg.Append ("c", null; F.Append (cg); F.SetItemStatelistener (this); Display.setcurrent (f); } protected void pauseapp () { // TODO automatic generation method stub } Protected Void DestroyApp (Boolean B) throws MidletStateChangeException { // TODO automatic generation method stub } Public void itemStateChanged (item item) { // TODO automatic generation method stub Choicegroup TMP = (choicegroup) item; System.out.println ("Choice" Tmp.getSelectedIndex () "SELECTED"); } } All mobile phones have seen a button that adjusts the volume, this button actually called the GUI interface element is gauge. There are 4 parameters in Gauge's construction, the first is the label of Gauge, the second is whether Gauge supports interaction with the user. The remaining two parameters are the length of this graphic. Let's take a look at the example. Oh, it feels like an example writer, this time writes a lot of writing this example. But there are also a lot of benefits, huh, at least let me remember a lot. So I suggest that the brothers don't rely on copy, paste to write their own code, and it is best to write in this way of learning. Package com.graph; / ** * @Author you li * * CopyRight (C) 2005 www.iguess.com.cn * / Import javax.microedition.lcdui. *; Import javax.microedition.midlet. *; Public class gaugetest extends midlet imports itemptionelistener { Private display display; Gauge G1; Gauge g2; Public gaugetest () { Display = display.getdisplay (this); // TODO automatically generates constructor stub } Protected void startapp () throws midletStateChangeException { // TODO automatic generation method stub Form f = new form ("formtest"); G1 = New Gauge ("Gauge1", True, 200, 100); G2 = New Gauge ("Gauge2", FLASE, 200, 100); F.Append (G1); F.Append (g2); F.SetItemStatelistener (this); Display.setcurrent (f); } protected void pauseapp () { // TODO automatic generation method stub } Protected Void DestroyApp (Boolean Arg0) throws midletStateChangeException { // TODO automatic generation method stub } Public void itemStateChanged (item item) { // TODO automatic generation method stub Gauge TMP = (Gauge) Item; IF (tmp.getlabel (). Equals ("gauge2")) { G1.setValue (tmp.getvalue ()); } } } Then the other object of Form, Datefield. Still writing a relatively simple time adjustment. Through this program, let's see the properties of Datefield. Package com.graph; / ** * @Author you li * * CopyRight (C) 2005 www.iguess.com.cn * / Import javax.microedition.midlet. *; Import javax.microedition.lcdui. *; Import java.util. *; Public Class DatefieldTest Extends Midlet Implements ItemStateListener { Private display display; Public DatefieldTest () { Display = display.getdisplay (this); // TODO automatically generates constructor stub } Protected void startapp () throws midletStateChangeException { // TODO automatic generation method stub Form f = new form ("formtest"); Date now = new date (); Datefield DF = New Datefield ("Datefield Test", Datefield.date_time); Df.setdate (now); F.Append (DF); F.SetItemStatelistener (this); Display.setcurrent (f); } protected void pauseapp () { // TODO automatic generation method stub } Protected Void DestroyApp (Boolean Arg0) throws midletStateChangeException { // TODO automatic generation method stub } Public void itemStateChanged (item item) { // TODO automatic generation method stub Datefield TMP = (Datefield) Item; Date d = tmp.getdate (); System.out.println (d.gettime ()); } } It has two properties when initializing Datefield, the first is the Datefield tag, the second is the input mode. MIDP provides three input modes for DateField. Datefield.date_time, datefield.date; datefield.time. (PS: Although there are three modes, but because in general, we need to enter the date and specific time, so I use the DateField.date_time mode in the example.) Then there is the last more important advanced graphics Handling transactions, Ticker, this type of implementation is similar to a running hogging program written by using JavaScript in HTML. Package com.graph; / ** * @Author you li * * CopyRight (C) 2005 www.iguess.com.cn * / Import javax.microedition.midlet. *; Import javax.microedition.lcdui. *; Public class tickertest extends midlet imports commandlistener { Private display display; Command commit; Public tickertest () { Display = display.getdisplay (this); // TODO automatically generates constructor stub } Protected void startapp () throws midletStateChangeException { // TODO automatic generation method stub Commit = New Command ("Commit", Command.screen, 1); TextBox TB = New TextBox ("Content", "Tickertest", 20, Textfield.Any; TB.SetTicker (New Ticker ("Ticker Test ..."); tb.addcommand (commit); Tb.setCommandListener (this); Display.SetCurrent (TB); } protected void pauseapp () { // TODO automatic generation method stub } Protected Void DestroyApp (Boolean Arg0) throws midletStateChangeException { // TODO automatic generation method stub } Public void CommandAction (Command Arg0, Displayable S) { // TODO automatic generation method stub TextBox TMP = (TextBox) S; System.out.println (tmp.getstring ()); } } You can use the Ticker's getString () method to get the text in the running hocker, or you can set the text content as the runa lamp with the setString () method. Several important advanced graphics processing elements in MIDP is almost so much. These days also looked at the study notes in the past few days, summed up a few more aspects that should pay attention to when doing handheld equipment. Oh, it is also a preparation that I am going to start doing actual development. First, the handheld equipment is not a PC, its screen, power supply, memory, etc. are very limited, so I think the graphic interface should be simple when doing actual development, and should not use the complex graphics interface. . Of course, huh, except the game. I am talking about the issue of application development. Second, try to use advanced graphics processing elements, there is no special need to make us to do platform shift value. Oh, at least when you do a program, you should use the advanced graphic processing element to complete the scribe module, and then use the low graphics processing element properly based on the SDK of the actual machine. Third, there is an element of the input box, in order to facilitate the fixed input method such as TextField.Numberic, so as not to use the keyboard in the keyboard to transform the user when using the keyboard when using it. ^ _ ^ Fourth, there seems to have a Kawt graphic processing package, and individuals are not recommended. This package is actually a simplified version of AWT, and there are some problems in processing graphics and compatibility. Oh, if you don't update the version, I think it is best not to use. ^ _ ^