首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

模拟器报java.lang.ClassNotFoundException: TestMIDlet异常

2014-01-26 
模拟器报java.lang.ClassNotFoundException:TestMIDlet异常:代码如下:package zhang.taoimport javax.micr

模拟器报java.lang.ClassNotFoundException:   TestMIDlet异常:

代码如下:

package zhang.tao;
 
  import javax.microedition.midlet.*;
  import javax.microedition.lcdui.*;
  import javax.microedition.lcdui.game.*;
 
  public class TestMIDlet extends MIDlet implements CommandListener{
 
  private Display d;
  private Command exit;
  private Command start;
  private TestCanvas test;
 
  public TestMIDlet() {
  super();
  // TODO 自动生成构造函数存根
  d = Display.getDisplay(this);
  exit = new Command("离开", Command.EXIT, 1);
  start = new Command("开始", Command.SCREEN, 1);
  test = new TestCanvas();
  }
 
  protected void startApp() throws MIDletStateChangeException {
  // TODO 自动生成方法存根
  test.addCommand(exit);
  test.addCommand(start);
  test.setCommandListener(this);
  d.setCurrent(test);
  }
 
  protected void pauseApp() {
  // TODO 自动生成方法存根
 
  }
 
  protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
  // TODO 自动生成方法存根
 
  }
  public void commandAction(Command c, Displayable d)
  {
  String str = c.getLabel();
  if(str.equals("开始"))
  {
  test.start();
  }
  if(str.equals("离开"))
  {
  try {
  destroyApp(false);
  } catch (MIDletStateChangeException e) {
  e.printStackTrace();
  }
  notifyDestroyed();
  }
  }
 
  }
 
  class TestCanvas extends GameCanvas implements Runnable
  {
  private boolean sign;
  private int x;
  private int y;
  private Graphics g;
 
  public TestCanvas()
  {
  super(true);
  x = getWidth()/2;
  y = getHeight()/2;
  }
  public void start()
  {
  sign = true;
  Thread t = new Thread(this);
  t.start();
  }
  public void run()
  {
  g = getGraphics();
  while(sign)
  {
  input();
  paint(g);
 
  try
  {
  Thread.sleep(15);
  }
  catch (Exception e)
  {
  }
 
  }
 
  }
  public void input()
  {
  int keyState = getKeyStates();
 
  switch(keyState)
  {
  case UP_PRESSED:
  y = Math.max(0, y-1);
  break;
  case DOWN_PRESSED:
  y = Math.min(getWidth(), y+1);
  break;
  case LEFT_PRESSED:
  x = Math.max(0, x-1);
  break;
  case RIGHT_PRESSED:
  x = Math.min(getHeight(), x+1);         

热点排行