第一个j2me程序

来源:互联网 发布:淘宝运费险在哪里设置 编辑:程序博客网 时间:2024/05/20 23:31

package com;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class mymidlet extends MIDlet implements CommandListener{
 private Form form;
 private final Command cmdExt = new Command("Exit",Command.EXIT,1);
 public mymidlet() {
  // TODO Auto-generated constructor stub
  form = new Form("hello j2me");
  form.append("This is a j2me");
  form.addCommand(cmdExt);
  form.setCommandListener(new CommandListener(){
   public void commandAction(Command arg0,Displayable arg1)
   {
    if(cmdExt == arg0){
     notifyDestroyed();
     try {
      destroyApp(true);
     } catch (MIDletStateChangeException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     }
    }
   }
  });
 }

 protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
  // TODO Auto-generated method stub

 }

 protected void pauseApp() {
  // TODO Auto-generated method stub

 }

 protected void startApp() throws MIDletStateChangeException {
  // TODO Auto-generated method stub
  Display.getDisplay(this).setCurrent(form);
 }

 public void commandAction(Command arg0, Displayable arg1) {
  // TODO Auto-generated method stub
  
 }

}

原创粉丝点击