Notes bought 2.5 pounds of coffee beans today, Starbuck's. A little bit expensive, with 599 of the ocean, oh, occasionally luxury can not be too. Just grinding a cup of coffee, lit cigarette, hehe, continue to start J2ME learning process. Although today in Saturday, but I do not expect to see much today, tomorrow to the company to work overtime, so today still want to have a break early ... Think about the last few weeks, Soho time every night is my work time, day. Hey, sleep ... That is really happy ... Good days no longer ...
Oh, TextBox, as if to see the name to know what to do, HTML inside the input box. Oh, the feeling should be similar. Write A (and TextBox has the same way to use another object: TextField, hehe, feel this is the HTML inside textarea just ^_^)
Test program First:
Package com.graph;
/**
* @author you Li
*
* CopyRight (C) www.iguess.com.cn
*/
Import javax.microedition.midlet.*;
Import javax.microedition.lcdui.*;
public class Textboxtest extends MIDlet implements commandlistener{
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 that is entered on the screen in the background. TextBox ("Input box", "Default", 12,textfield.any), which is used to set the properties of the dialog box. I tested it today and looked at the document, mainly in the last two properties, where the number represents the maximum number of characters that the input box can accept. textfield.any-arbitrary characters, textfield.emailaddr-accept email address, textfield.numeric-only accept digital input, textfield.password-input password; textfield.phonenumber- Enter the phone number, which means that you can accept numbers, spaces, asterisks, well numbers; textfield.url-accepts input url;textfield.constraint_mask-used to getconstraints textbox () method returns the result of an and logical operation, and then the current qualifying setting can be obtained. Of course, this parameter should not be used when the textbox is created.
Oh, the textbox I learned these days the simplest and easiest thing, hehe, seems to be in a good mood today, may be the role of Starbucks Oh. Oh... By the way, say Han, drink coffee if you like to add milk must be coffee into the milk, so the coffee inside the milk flavor is more honest ^_^ is also my habit, of course, I never put sugar, I think that the damage of coffee original sour. Grinding a cup of freshly grated coffee at rest will make you feel the elegance of your life right away and leave you temporarily out of the city's troubles. Coffee & cigarettes, a quiet weekend plus j2me information, feel good:
Oh, pull away the =_=!
To start again, it doesn't make any sense to have a form exist alone, as in HTML. It must contain subclasses of the item class to be useful.
Write a test procedure for a form:
Package com.graph;
Import javax.microedition.midlet.*;
Import javax.microedition.lcdui.*;
/**
* @author you Li
*
* CopyRight (C) www.iguess.com.cn
*/
public class Formtest extends MIDlet implements Commandlistener,itemstatelistener {
public void Commandaction (Command C, displayable s) {
TODO automatically generate method stubs
form tmp = (form) s;
for (int i = 0;i < Tmp.size (); i++) {
Stringitem si = (stringitem) tmp.get (i);
Get () method fetch value is item class, so need to force convert flavor Stringitem class.
System.out.println (Si.gettext ());
}
}
public void itemstatechanged (Item arg0) {
TODO automatically generate method stubs
}
}
Oh, basically the program inside although there is no comment, but the whole stringitem itself is not very complicated. So there are not too many records. And the use of Imageitem and Stringitem is basically the same. It is constructed in such a way that:
Append (new Imageitem (symbol text, image object, position control parameter, alternative text);
Imageitem position parameters are mainly as follows: Imageitem.layout_default;imageitem.layout_left;imageitem.layout_right;imageitem.layout_ Center;imageitem.layout_newline_before;imageitem.layout_neline_after
Another method of its construction is append (new Image ()), which is equivalent to invoking the append (The new Imageitem (Null,image object, Imageitem.layout_default, NULL) to construct the Imageitem object.
Choicegroup, when the form is used in conjunction with Choicegroup, it is the same as the previous list, because Choicegroup and the list will build a choice selection box for us. Or look at the procedure first:
Package com.graph;
/**
* @author you Li
*
* CopyRight (C) www.iguess.com.cn
*/
Import javax.microedition.midlet.*;
Import javax.microedition.lcdui.*;
public class Choicegrouptest extends MIDlet implements Itemstatelistener {
All of the phones we see a button to adjust the volume, which actually calls the GUI interface element is gauge. Gauge's construction method has 4 parameters, the first is the gauge tag, and the second is whether gauge supports interacting with the user. The remaining two parameters are the length and width of the graph.
Let's take a look at the examples. Oh, feel like an example writer, this time writing this example wrote a lot. But there are a lot of benefits, hehe, at least let me remember a lot of things. So I suggest that brothers do not copy, paste to write their own code, it is best this learning phase on one line of writing.
Package com.graph;
/**
* @author you Li
*
* CopyRight (C) www.iguess.com.cn
*/
Import javax.microedition.lcdui.*;
Import javax.microedition.midlet.*;
public class Gaugetest extends MIDlet implements Itemstatelistener {
Then there is another object of form, Datefield. Or write a relatively simple time adjustment. Through this program we look at the various properties of Datefield.
Package com.graph;
/**
* @author you Li
*
* CopyRight (C) www.iguess.com.cn
*/
Import javax.microedition.midlet.*;
Import javax.microedition.lcdui.*;
Import java.util.*;
public class Datefieldtest extends MIDlet implements Itemstatelistener {
When initializing the Datefield, it has two properties, the first is the Datefield label, and the second is the input mode. MIDP provides three input modes altogether for Datefield. Datefield.date_time,datefield.date;datefield.time. PS: Although there are three modes, but because generally we enter all need date and time input, so I in the example is the Datefield.date_time mode. )
Then there is the last important high-level graphics processing transaction, ticker, the effect of this class implementation is similar to the HTML inside the use of JavaScript written in a marquee program effect.
Package com.graph;
/**
* @author you Li
*
* CopyRight (C) www.iguess.com.cn
*/
Import javax.microedition.midlet.*;
Import javax.microedition.lcdui.*;
public class Tickertest extends MIDlet implements Commandlistener {
public void Commandaction (Command arg0, displayable s) {
TODO automatically generate method stubs
TextBox tmp = (textbox) s;
System.out.println (Tmp.getstring ());
}
}
You can use the ticker GetString () method to get the text in the marquee, or you can set the text content for the marquee by using the SetString () method.
Some of the most important advanced graphics processing elements in MIDP are almost as much. These days also took a few days before the study notes, summed up a few do handheld devices when the development should pay attention to. Oh, is also considered to be ready to start the actual development of a preparation bar.
First, the handheld device is not a PC, its screen, power supply, memory and so are very limited, so I think in the actual development of the graphics interface should be simple, should not be too much use of complex graphics interface. Of course, hehe, except for games. I'm talking about the problem of doing application development.
Second, as far as possible use of advanced graphics processing elements, there is no special need to do so in favor of us to do platform shift values. Oh, at least when you do a program should use advanced graphics processing elements to complete the basic module, and then in accordance with the actual machine SDK appropriate use of low-level graphics processing elements.
Third, there are input box elements, in order to facilitate the use of textfield.numberic and other fixed input methods, so that users in the use of the time too much by the keyboard to convert character elements ^_^
Four, there seems to be a KAWT graphics processing package, the individual is not very recommended use. This package is actually a simplified version of AWT, and there are some problems with the efficiency and compatibility of the graphics. Oh, if not out of the updated version I think it is best not to use slightly. ^_^
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.