At first, talking about transaction is sure to think that a variety of different concepts, the inheritance of the Java base class. So feel very boring. In
When I was in front of Java, I was a headache. Ha ha. Oh, start studying the transaction processing of MIDlet. In fact, I have never written Applet, but the servlet is much written.
After all, the status of servlet in MVC is also important. Any servlet must inherit javax.servlet.http.httpservle
Type, in fact, as a MIDLET is also a concept, all MIDlet must inherit javax.microedition.midlet.mid
Let. To put it bluntly, it inherits three methods for startapp (), pauseapp () and destoryApp (). When a MIDLET successfully started, its life cycle is started, and this lifecycle is completely JPM control. MIDLET
When the state transition occurs, the MIDletStateChangeException will be thrown. In the entire MIDP specification, transaction processing is divided into advanced transaction processing and low-level transaction processing. Low-level transaction processing according to different handheld devices
There will be different class library support, while advanced transaction processing has no limit. That is, if we do the MIDlet to do it on different machines
You can run the method in low-level transaction processing, but can only use the method in advanced transaction processing. In the entire MIDP, transaction processing is formed by a combination of transactions <-> processing methods. MIDP All components with display capabilities are inherited in the Displayable abstraction class, which is derived from Screen.
理) and Canvas (handling low-level transaction processing). There are two interfaces in the MIDP in the MIDP, named COMMANDLISTENER, and ITE.
MSTATELISTENER. The CommandListener interface is often used with the Command class in javax.microedition.lcdui. can
See the following example: / ** * @AuThor you li * * Copyright (c) 2005 * / import javax.microedition.midlet. *; Import javax.microedition.lcdui. *;
public class HLEventMIDlet extends MIDlet implements CommandListener {private Command exitCommand; private Command info1Command; private Command info2Command; private Display display; public HLEventMIDlet () {display = Display.getDisplay (this); exitCommand = new Command ( "Exit", Command.SCREEN 1); // The smaller the number of numbers, the priority level
The higher INFO1COMMAND = New Command ("Menu 1", Command.Screen, 2); Info2Command = New Command ("Menu 2", Command.Screen, 2); PUBLIC VOID StartApp () {TextBox T = New TextBox (" Hello "," Test ^ _ ^ ", 256, 0); T.SetCommandListener (this); t.addcommand; t.addcommand; t.addcommand (info1command); Display.SetCurrent (T) ;} public void pauseApp () {} public void destroyApp (boolean unconditional) {} public void commandAction (Command c, Displayable s) {if (c == exitCommand) {notifyDestroyed ();} else if (c == info1Command) {NOTIFYDESTROYED ();}}} After running, you will find a simple menu that you have to choose from! ^ _ ^ Command defines eight commands, priority levels from high to low: command.back command.cancel command.exit command.help command.Item Command.ok Command.screen
Command.stop. Oh, I don't think there is nothing to use, and I will be clear about writing a little code. . ^ _ ^
CommandListener uses Unicast mode, so at the same time, it can only be able to handle a transaction method accordingly.
Then appreciate the Hain ItemStatelistener interface. Like CommadnListener, it also uses Unicast mode. Made a list: / ** * @Author you li * * CopyRight (c) 2005 * / import javax.microedition.midlet. *; Import javax.microedition.lcdui. *;
Public class tfeventmidlet extends Midlet imports itemptionelistener {
/ ** * * / private displaphic tfEventMidlet () {display = display.getdisplay (this);} public void startapp () {form f = new form ("form"); TextField TF = New TextField ("Input" "," Origin ", 25, Textfield.Any; F.Append (TF); F.SetItemStateListener (this); Display.setCurrent (f);} public void pauseapp () {} public void destroyApp (boolean unconditional) { } Public void itemStatechanged (item item) {textfield TMP = (TextField) Item; Tmp.SetString ("Changed");
} There should be no need to write about the specific usage of these two interfaces. If you need to inherit the class, I think it is almost. . Oh, naming is still very standardized.
According to MIDP specification, if CommandListener and ItemStateListener are handled, ItemStateChanged () takes precedence over Comm
AndAction () processing.
Advanced transactions are very simple, but functions do not really meet our needs. So this time we have to
Handled with low-level transactions.
I don't want to see it today. . More tired, huh, huh, so low-level transactions are studying tomorrow morning.