J2ME study notes (c )—– learning MIDlets

  Dealing with MIDlets 

  1. MIDlet using CLDC MIDP features and application configuration MIDlet 

  1). MIDlet is packaged into JAD (JAVA descriptors) files Java class files 

  2). MIDlet running on the MIDP equipment has been installed in the Application Management Software (AMS application management software). AMS provides KVM and the environment MIDlets 

  3). MIDlet in support of the MIDP CLDC and the use of handheld devices. 

  2. MIDlet life cycle (AP) 

  3. Examples of the development of MIDlets 

  1). Mission statement —– SaveMyMoney mobile banking application on the screen to show the news as "Welcome to SaveMyMoney Bank!", The top of the screen there is a news show, "Welcome to the World of Mobile Banking!" rolling text; 

  The second screen to show the news as "Dear Customer, You can view your personal account information by entering your PIN number and sending it to the number 9002. If you have not received the PIN number, please contact us at our Head Office. "top of the screen displays a message there is a" Note: Your PIN number has been sent to you at your mailing address. "rolling text 

  2). Code as follows —– 

  Import javax.microedition.midlet .*; 

  Import javax.microedition.lcdui .*; 

  / / Need to achieve in category CommandListener lcdui Interface 

  Public class MB extends MIDlet implements CommandListener 

  ( 

  / / Display category management with user input and display 

  Display display; 

  Form form1; 

  Form form2; 

  / / Definition of the two rolling ticker1, ticker2 

  Ticker ticker1; 

  Ticker ticker2; 

  Static final Command okCommand = new Command ( "Info", Command.OK, 1); 

  Static final Command backCommand = new Command ( "Back" Command.BACK, 0); 

  Static final Command exitCommand = new Command ( "Exit", Command.STOP, 2); 

  Public MB () 

  ( 

  ) 

  Public void startApp () throws MIDletStateChangeException 

  ( 

  Ticker1 = new Ticker ( "Welcome to the World of Mobile Banking!"); 

  Ticker2 = new Ticker ( "Note: Your PIN number has been sent to you at your mailing address."); 

  Display = Display.getDisplay (this); 

  Form1 = new Form ( "SaveMyMoney"); 

  Form2 = new Form ( "CUSTOMER CARE"); 

  StringItem strItem = new StringItem ( "Welcome to SaveMyMoney Bank!", ""); 

  StringItem strItem1 = new StringItem ( "Dear Customer," and "You can view your personal account information by entering your PIN number and sending it to the number 9002. If you have not received the PIN number, please contact us at our Head Office. "); 

  Form1.append (strItem); 

  Form2.append (strItem1); 

  / / Added to the order screen, a screen on the left is Ruanjian Exit, and the right is OK Ruanjian 

  Form1.addCommand (exitCommand); 

  Form1.addCommand (okCommand); 

  / / MONITORING 

  Form1.setCommandListener (this); 

  Form1.setTicker (ticker1); 

  / / Set up the main screen displays the current Form1 

  Display.setCurrent (form1); 

  ) 

  Public void pauseApp () 

  ( 

  ) 

  Public void destroyApp (boolean unconditional) 

  ( 

  NotifyDestroyed (); 

  ) 

  Public void showForm1 () 

  ( 

  Form1.addCommand (exitCommand); 

  Form1.addCommand (okCommand); 

  Form1.setCommandListener (this); 

  Display.setCurrent (form1); 

  ) 

  Public void showForm2 () 

  ( 

  Form2.addCommand (exitCommand); 

  Form2.addCommand (backCommand); 

  Form2.setCommandListener (this); 

  Form2.setTicker (ticker2); 

  Display.setCurrent (form2); 

  ) 

  Public void commandAction (Command cmd, Displayable displayable) 

  ( 

  String label = cmd.getLabel (); 

  If (label.equals ( "Exit")) 

  ( 

  / / Call MIDlet action and withdraw from this application 

  DestroyApp (true); 

  ) 

  Else if (label.equals ( "Back")) 

  ( 

  / / Go back to Form1 

  ShowForm1 (); 

  ) 

  Else 

  ( 

  ShowForm2 (); 

  ) 

  ) 

  ) 

  Test results are as follows: 

Bookmark it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • DotNetKicks
  • DZone
  • Furl
  • Netvouz

Tags:

Releated Articles


0 Comments to “J2ME study notes (c )—– learning MIDlets”

No Comments. Send your comment.

Leave a Reply

You must be logged in to post a comment.