//9.1.1  ĻʾĻ Canvas
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class MyCanvas extends Canvas{
    private MIDlet midlet;
    public MyCanvas( MIDlet midlet ){
        this.midlet = midlet;
    } 
 
    protected void paint( Graphics g ){
        g.setColor( 255, 255, 255 );  // ɫ
        g.fillRect( 0, 0, getWidth(), getHeight() );  // ƾ
        g.setColor( 0, 0, 0 );
        g.drawString( "Hello,World! ", getWidth()/2, 0,g.TOP | g.HCENTER );
    }
}


//9.1.2  ʹCanvasġHello,World!
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class CanvasHelloMIDlet extends MIDlet{
    private Display  display;
    private MyCanvas canvas;   
    public CanvasHelloMIDlet (){
        display = Display.getDisplay( this );
        canvas  = new MyCanvas( this );  // ɻ
    }
    protected void startApp(){
        display.setCurrent( canvas );  // ʾ
    }   
    protected void pauseApp(){}  
    protected void destroyApp( boolean unconditional ){}   
    public void exit(){
        destroyApp( true );
        notifyDestroyed();
    }
}


//9.1.3  ˳ķ
import javax.microedition.midlet.*;

public class CanvasHelloMIDlet2 extends MIDlet implements CommandListener {
    private Display  display;
    private MyCanvas canvas;
    private Command  exitCommand = new Command( 
                          "Exit", Command.SCREEN, 1 );
   
    public MyMIDlet(){
        display = Display.getDisplay( this );
        canvas = new MyCanvas( this );  // ɻ
        canvas.addCommand( exitCommand );
        canvas.setCommandListener( this );
    }
   
    protected void startApp(){
        display.setCurrent( canvas );
    }
   
    protected void pauseApp(){}
  
    protected void destroyApp( boolean unconditional ){}
   
    public void exit(){
        destroyApp( true );
        notifyDestroyed();
    }
    public void commandAction( Command c, Displayable d ){
        if( c == exitCommand ){
            exit();
        }
    }
}


//9.2.4  Ӧظָƶ¼
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class HappyPush extends MIDlet implements AppExiter
{
   protected void startApp(){
      // ʾĻ
      Display.getDisplay(this).setCurrent(new HappyPushScreen(this));
   }
   protected void pauseApp(){}
   protected void destroyApp(boolean unconditional){
      notifyDestroyed();
   }
   public void exitApp(){
      destroyApp(true);
   }
}
class HappyPushScreen extends Canvas implements CommandListener{
   // ٶйصļ
   private int          m_maxX = getWidth() - 1;
   private int          m_maxY = getHeight() - 1;
   private int          m_imageWidth;
   private int          m_imageHeight;
   // ƶֵ
   private int          m_x = m_maxX / 2;
   private int          m_prevX = m_maxX / 2;
   private int          m_y = m_maxY / 2;
   private int          m_prevY = m_maxY / 2;
   private AppExiter    m_appExiter;
   private Image        m_face;
   private KeyRepeater  m_repeat = new KeyRepeater();
   /**
    * ڹ캯ɼͼ,
    *  ʼ, EXIT ť
    */
   public HappyPushScreen(AppExiter exiter){
      m_appExiter = exiter;
      
      try{
         m_face = Image.createImage("/face.png");
      }catch (Exception e){
         m_face = null;
      }
      // һЩֵ
      m_imageWidth = m_face.getWidth();
      m_imageHeight = m_face.getHeight();
      // ڻEXITť
      addCommand(AppExiter.EXIT);
      setCommandListener(this);
      m_repeat = new KeyRepeater();
      m_repeat.start();
   }
   
   protected void paint(Graphics g){
      // ͼ
      g.setColor(0xffffff);
      g.fillRect(m_prevX-m_imageWidth/2, m_prevY-m_imageHeight/2, 
m_imageWidth, m_imageHeight);
      g.setColor(0);
      // ͼ
      g.drawImage(m_face, m_x, m_y, Graphics.VCENTER|Graphics.HCENTER);
      // λȡλ
      m_prevX = m_x;
      m_prevY = m_y;
   }
   protected void keyRepeated(int keyCode){
      if (hasRepeatEvents()){
         moveFace(getGameAction(keyCode));
      }
   }
   protected void keyPressed(int keyCode){
      if (!hasRepeatEvents()){
         m_repeat.startRepeat(keyCode);
      }
      moveFace(getGameAction(keyCode));
   }
   protected void keyReleased(int keyCode){
      if (!hasRepeatEvents()){
         m_repeat.stopRepeat(keyCode);
      }
   }
   private void moveFace(int gameAction){
      switch(gameAction){
      case UP:
         if (m_y > 0) m_y--;
         break;
      case LEFT:
         if (m_x > 0) m_x--;
         break;
      case DOWN:
         if (m_y < m_maxY) m_y++;
         break;
      case RIGHT:
         if (m_x < m_maxX) m_x++;
         break;
      }
      // Ļʾƽ
      repaint();
   }
   protected void pointerPressed(int x, int y){
      if (hasPointerEvents()){
         m_y = y;
         m_x = x;
         repaint();
      }
   }
   protected void pointerDragged(int x, int y){
      if (hasPointerMotionEvents()){
         pointerPressed(x, y);
      }
   }
   public void commandAction(Command c, Displayable d){
      if (c == HappyPush.EXIT){
         m_repeat.done();
         m_repeat = null;
         m_appExiter.exitApp();
      }
   }
   class KeyRepeater extends Thread{
      private boolean m_done = false;
      private int m_gameAction;
      public synchronized void done(){
         m_done = true;
      }
      public synchronized void startRepeat(int keyCode){
         m_gameAction = getGameAction(keyCode);
      }
      public synchronized void stopRepeat(int keyCode){
         if (getGameAction(keyCode) == m_gameAction){
            m_gameAction = 0;
         }
      }
      public void run(){
         while (!m_done){
            // ߳
            while (m_gameAction == 0 && !m_done){
               Thread.yield();
            }
            // ȴһʱ,߳׼
            synchronized (this){
               try{
                  sleep(10);
               }catch (InterruptedException e){
               }
            }
            moveFace(m_gameAction);
         }
      }
   }
}
interface AppExiter{
   public static final Command EXIT = new Command("Exit", Command.EXIT, 1);
   public void exitApp();
}


//9.3.1  ʹñķ
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class AlertSplashMIDlet extends MIDlet implements CommandListener
{
  private Display display; 
  private TextBox tbxMain; // ʾϢTextbox 
  private Command cmdExit; // ˳MIDletİť

  public AlertSplashMIDlet()
  {
    display = Display.getDisplay(this);

    cmdExit = new Command("Exit", Command.SCREEN, 1);

    tbxMain = new TextBox("HelloWorld MIDlet", "Hello,World!", 50, 0);
    tbxMain.addCommand(cmdExit);
    tbxMain.setCommandListener(this);
  }

  public void startApp(){
	ShowSplashScreen(display, tbxMain);
  }

  public void pauseApp(){ }

  public void destroyApp(boolean unconditional){ }

  public void commandAction(Command c, Displayable s){
    if (c == cmdExit){
       destroyApp(false);
       notifyDestroyed();
    } 
  }

  public void ShowSplashScreen(Display d, Displayable next ){
    Image logo = null;
    
    try {
      logo = Image.createImage("logo.png" );  // ͼ
    }
    catch( Exception e ){}
    
    Alert a = new Alert( "Time Tracker", 
           "Copyright 2002 by Deartony, UESTC",logo, null ); 
    a.setTimeout( Alert.FOREVER );
    display.setCurrent( a, next );
  } 
}


//9.3.2  ʹCanvas
import java.util.*;
import javax.microedition.lcdui.*;

public class SplashScreen extends Canvas {
    private Display     display;
    private Displayable next;
    private Timer       timer = new Timer();  // һʱ

    public SplashScreen(Display display, Displayable next){
        this.display = display;
        this.next    = next;

        display.setCurrent( this );
    }

    protected void keyPressed( int keyCode ){
        dismiss();
    }

    protected void paint( Graphics g ){}

    protected void pointerPressed( int x, int y ){
        dismiss();
    }

    protected void showNotify(){
        timer.schedule( new CountDown(), 5000 );  // öʱ
    }

    private void dismiss(){
        timer.cancel();
        display.setCurrent( next );
    }

    private class CountDown extends TimerTask {
        public void run(){
            dismiss();
        }
    }
}

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class SplashMIDlet extends MIDlet implements CommandListener {
    private Display display;
    private Command exitCommand = new Command("Exit", Command.EXIT, 1 );
    public SplashMIDlet(){}
    protected void destroyApp(boolean unconditional)
               throws MIDletStateChangeException {
        exitMIDlet();
    }
    protected void pauseApp(){}
    protected void startApp() throws MIDletStateChangeException {
        if( display == null ){
            initMIDlet();
        }
    }
    private void initMIDlet(){
        display = Display.getDisplay( this );
        new SplashScreen(display, new TrivialForm() );  // 
    }
    public void exitMIDlet(){
        notifyDestroyed();
    }
    public void commandAction(Command c, Displayable d ){
        exitMIDlet();
    }
    class TrivialForm extends Form {
        TrivialForm(){
            super( "SplashScreen Demo" );
            addCommand( exitCommand );
            setCommandListener( SplashMIDlet.this );
        }
    }
} 


//9.4.2  ScreenSaverĴ
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;

public class ScreenSaver extends MIDlet{
  private Display  display;			// Display
  private Timer timer;				// Timer
  private LinesTimerTask task;		// Task
  private ScreenSaverCanvas canvas;   // Canvas 
 
  public ScreenSaver()
  {
    display = Display.getDisplay(this);
    canvas  = new ScreenSaverCanvas(this);
    
    // һ 500 ִһε
    timer = new Timer();
    task = new LinesTimerTask(canvas);
    timer.schedule(task, 0, 500);    
  }
 
  protected void startApp()
  {
    display.setCurrent( canvas );
  }
 
  protected void pauseApp() { }

  protected void destroyApp( boolean unconditional ) { }
 
  public void exitMIDlet()
  {
    destroyApp(true);
    notifyDestroyed();
  }
}

/*--------------------------------------------------
* ScreenSaverCanvas 
*
* 
*-------------------------------------------------*/
class ScreenSaverCanvas extends Canvas implements CommandListener
{
  private Command cmExit;		// Exitť
  private Command cmClear;		// Clearť
  protected int startx = 0,		// ߵĿʼλ
              starty = 0,
              endx = 0,			// ߵĽλ
              endy = 0;
  private ScreenSaver midlet;
  private boolean clearDisplay = false;
  protected int linesDrawn = 0;   // ¼ߵ
  private static final int MAX_LINES = 100;

  /*--------------------------------------------------
  * Constructor
  *-------------------------------------------------*/
  public ScreenSaverCanvas(ScreenSaver midlet)
  {
    this.midlet = midlet;
    
    // Exitť
    cmExit = new Command("Exit", Command.EXIT, 1);
    cmClear = new Command("Clear", Command.SCREEN, 1);    
    addCommand(cmExit);
    addCommand(cmClear);
    setCommandListener(this);
  } 

  /*--------------------------------------------------
  * һ
  *-------------------------------------------------*/
  protected void paint(Graphics g)
  {
    // Ĺ
    if (clearDisplay || linesDrawn > MAX_LINES)
    {
      g.setColor(255, 255, 255);
      g.fillRect(0, 0, getWidth(), getHeight());
      
      startx = endx = starty = endy = 0;
      clearDisplay = false;      
      linesDrawn = 0;
        
      return;
    }
    
    // ûɫΪɫ
    g.setColor(0, 0, 0);
    
    // һ
    g.drawLine(startx, starty, endx, endy);
    
    // ǰλΪµλ
    startx = endx;
    starty = endy;
  }

  /*--------------------------------------------------
  * 
  *-------------------------------------------------*/  
  public void commandAction(Command c, Displayable d)
  {
    if (c == cmExit)
      midlet.exitMIDlet();
    else if (c == cmClear)
    {
      clearDisplay = true; 
      repaint();
    }
  }
}

class LinesTimerTask extends TimerTask
{
  private ScreenSaverCanvas canvas;
  private Random random;
  
  public LinesTimerTask(ScreenSaverCanvas canvas)
  {
    random = new java.util.Random();
    this.canvas = canvas;
  }

  /*--------------------------------------------------
  * һߵյ
  *-------------------------------------------------*/  
  public final void run()
  {
    // һ,ȷĻߴ
    canvas.endx = (random.nextInt() >>> 1) % canvas.getWidth();
    canvas.endy = (random.nextInt() >>> 1) % canvas.getHeight();
    
    // ¼˶
    canvas.linesDrawn++;
    
    canvas.repaint();
  }
}


//9.5.2  
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class ClearDisplay extends MIDlet{
  private Display  display;       
  private TextCanvas canvas;     
 	
  public ClearDisplay()
  {
    display = Display.getDisplay(this);
    canvas  = new TextCanvas(this);
  }
 
  protected void startApp()
  {
    display.setCurrent(canvas);
  }
 
  protected void pauseApp(){ }

  protected void destroyApp( boolean unconditional ){ }

  public void exitMIDlet()
  {
    destroyApp(true);
    notifyDestroyed();
  }
}

/*--------------------------------------------------
* TextCanvas 
*
* ı
*-------------------------------------------------*/
class TextCanvas extends Canvas implements CommandListener
{
  private Command cmExit;
  private Command cmClear; 
  private ClearDisplay midlet;
  private boolean clearDisplay = false;
  private String txt = "Text Message...";
 
  public TextCanvas(ClearDisplay midlet)
  {
    this.midlet = midlet;
    
    // ť
    cmExit = new Command("Exit", Command.EXIT, 1);
    cmClear = new Command("Clear", Command.SCREEN, 2);    
    
    addCommand(cmExit);
    addCommand(cmClear);    
    setCommandListener(this);
  } 

  /*--------------------------------------------------
  * ı
  *-------------------------------------------------*/
  protected void paint(Graphics g)
  {
    if (clearDisplay)
    {
      // 
      g.setColor(255, 255, 255);
      g.fillRect(0, 0, getWidth(), getHeight());
      clearDisplay = false;
    }
    else
    {
      // úɫ
      g.setColor(0, 0, 0);
      g.drawString(txt, getWidth()/2, getHeight()/2,
                      Graphics.TOP | Graphics.HCENTER);   
    }
  }

  /*--------------------------------------------------
  * ¼
  *-------------------------------------------------*/
  public void commandAction(Command c, Displayable d)
  {
    if (c == cmExit)
      midlet.exitMIDlet();
    else if (c == cmClear)
    {
      clearDisplay = true;
      repaint();
    }
  }
}


//9.6.1  ʾصPngͼƬ
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
/*--------------------------------------------------
* ඨ
*-------------------------------------------------*/
public class PngViewer extends MIDlet implements CommandListener
{
  private Display display;
  private TextBox tbMain;
  private Form fmViewPng;
  private Command cmExit;
  private Command cmView;
  private Command cmdBack;

  /*--------------------------------------------------
  * 캯
  *-------------------------------------------------*/
  public PngViewer()
  {
    display = Display.getDisplay(this);

    // 50ַı
    tbMain = new TextBox("Enter png url", "http://127.0.0.1/spin.png", 50, 0);

    // ť,ӵı
    cmView = new Command("View", Command.SCREEN, 1);
    cmExit = new Command("Exit", Command.SCREEN, 1);
    tbMain.addCommand(cmView );
    tbMain.addCommand(cmExit);

    // ť¼
    tbMain.setCommandListener(this);

    // ---------------------------------------

    // ʾͼƬĴ
    fmViewPng = new Form("Png Image");

    // ڴдť
    cmdBack = new Command("Back", Command.BACK, 1);
    fmViewPng.addCommand(cmdBack);

    // ť¼
    fmViewPng.setCommandListener(this);
  }

  /*--------------------------------------------------
  * MIDletʼʱִ
  *-------------------------------------------------*/
  public void startApp()
  {
    // ʾı
    display.setCurrent(tbMain);
  }

  public void pauseApp()
  { }

  public void destroyApp(boolean unconditional)
  { }

  /*--------------------------------------------------
  * ¼
  *-------------------------------------------------*/
  public void commandAction(Command c, Displayable s)
  {
    // "Exit"ť
    if (c == cmExit)
    {
      destroyApp(false);
      notifyDestroyed();
    }
    else if (c == cmView)  // "View"ť
    {
      // ɾĻϵһ
      if (fmViewPng.size() > 0)
        for (int i = 0; i < fmViewPng.size(); i++)
          fmViewPng.delete(i);

      try
      {
       // ͼƬڴ
        Image im;
        if ((im = getImage(tbMain.getString())) != null)
          fmViewPng.append(im);

        // ʾͼƬĴ
        display.setCurrent(fmViewPng);
      }
      catch (Exception e)
      { 
        System.err.println("Msg: " + e.toString());
      }
    }
    else if (c == cmdBack)  // "Back"ť
      display.setCurrent(tbMain);
  }

  /*--------------------------------------------------
  * һHTTPӣһpng ļ
  * һֽ
  *-------------------------------------------------*/
  private Image getImage(String url) throws IOException
  {
    ContentConnection connection = (ContentConnection) Connector.open(url);
    DataInputStream iStrm = connection.openDataInputStream();    
        
    Image im = null;

    try
    {
      // ȡݵĳ
      byte imageData[];
      int length = (int) connection.getLength();
      if (length != -1)
      {
        imageData = new byte[length];

        // ȡͼƬݵ
        iStrm.readFully(imageData);
      }
      else  // ϢЧ
      {       
        ByteArrayOutputStream bStrm = new ByteArrayOutputStream(); 
        
        int ch;
        while ((ch = iStrm.read()) != -1)
          bStrm.write(ch);
        
        imageData = bStrm.toByteArray();
        bStrm.close();                
      }

      // ֽдͼ
      im = Image.createImage(imageData, 0, imageData.length); 
    }
    finally
    {
      // Դ
      if (iStrm != null)
        iStrm.close();
      if (connection != null)
        connection.close();
    }
    return (im == null ? null : im);
  }
}


//9.6.2  ʵֹʾͼ
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
 * ʾͼ
*/
public class ImageMove extends MIDlet implements AppExiter{
   // MIDletʼʱִ
   protected void startApp(){
      Display.getDisplay(this).setCurrent(new ImageMoveScreen(this));
   }
   /**
    * MIDletͣʱִ
    */
   protected void pauseApp() 
   {
   }
   /**
    * MIDletʱִ
    */
   protected void destroyApp(boolean unconditional) 
   {
      notifyDestroyed();
   }
   public void exitApp() 
   {
      destroyApp(true);
   }
}
class ImageMoveScreen extends Canvas implements CommandListener
{
   // ƶٶصļֵ
   private int          m_screenWidth = getWidth();
   private int          m_screenHeight = getHeight();
   private int          m_imageWidth;
   private int          m_imageHeight;
   // ƶصֵ
   private int          m_x;
   private int          m_y;
   private int          m_dx = 0;
   private int          m_dy = 0;

   private AppExiter    m_appExiter;
   private KeyRepeater  m_repeat = new KeyRepeater();
   private Image        m_origImage;
   private Image        m_screenBuf;
   private Graphics     m_bufferGraphics;
   /**
    * 캯ͼ,ʼ 
    *  ȻEXIT ť
    */
   public ImageMoveScreen(AppExiter exiter)
   {
      m_appExiter = exiter;
      try
      {
         m_origImage = Image.createImage("/boat.png");
      }
      catch (Exception e)
      {
         m_origImage = null;
      }
      // һЩֵ
      m_imageWidth = m_origImage.getWidth();
      m_imageHeight = m_origImage.getHeight();
      m_x = (m_screenWidth - m_imageWidth)/2;
      m_y = (m_screenHeight - m_imageHeight)/2;
      // Ļ
      m_screenBuf = Image.createImage(m_screenWidth, m_screenHeight); 
// Front graphics m_screenBuffer
      m_bufferGraphics = m_screenBuf.getGraphics();
      m_bufferGraphics.setColor(0,0,0);
      m_bufferGraphics.fillRect(0,0,m_screenWidth,m_screenHeight);
      // EXITť
      addCommand(AppExiter.EXIT);
      // עᰴť¼
      setCommandListener(this);
      m_repeat = new KeyRepeater();
      m_repeat.start();
   }
   
   /**
    * ĻϻеĲ
    *
    */
   protected void paint(Graphics g)
   {
      m_bufferGraphics.drawImage(m_origImage, m_x, m_y, 
m_bufferGraphics.TOP|m_bufferGraphics.LEFT);
      g.drawImage(m_screenBuf, 0, 0, Graphics.TOP|Graphics.LEFT);
      g.setColor(255,255,255);
      g.drawString(m_x + " " + m_y, 0, 0, Graphics.TOP|Graphics.LEFT);
   }
   /**
    * ظʱ
    * keyCode ǰĴ
    */
   protected void keyRepeated(int keyCode)
   {
      if (hasRepeatEvents())
      {
         moveImage(getGameAction(keyCode));
      }
   }
   /**
    * ʱ
    *
    * keyCodeĴ
    */
   protected void keyPressed(int keyCode)
   {
      if (!hasRepeatEvents())
      {
         m_repeat.startRepeat(keyCode);
      }
      moveImage(getGameAction(keyCode));
   }
   /**
    * ͷʱ
    *
    * keyCode ǰĴ
    */
   protected void keyReleased(int keyCode)
   {
      if (!hasRepeatEvents())
      {
         m_repeat.stopRepeat(keyCode);
      }
   }
   private void moveImage(int gameAction)
   {
      // ǰӳĴ
      switch(gameAction)
      {
      case UP:
         if (m_y < 0) m_y++;
         break;
      case DOWN:
         if (m_y > m_screenHeight - m_imageHeight) m_y--;
         break;
      case LEFT:
         if (m_x < 0) m_x++;
         break;
      case RIGHT:
         if (m_x > m_screenWidth - m_imageWidth) m_x--;
         break;
      }
      // Ļ
      repaint();
   }
   /**
    * ʹָʱ
    * 
    * ָPDAʹõ
    *
    *  x ָˮƽ
    *  y ָĴֱ 
    */
   protected void pointerPressed(int x, int y)
   {
      if (hasPointerEvents())
      {
         m_dx = x;
         m_dy = y;
      }
   }
   /**
    * ָ϶ʱ
    * 
    *
    *  x ָˮƽλ
    *  y ָĴֱλ
    */
   protected void pointerDragged(int x, int y)
   {
      if (hasPointerMotionEvents())
      {
         m_y += y - m_dy;
         m_x += x - m_dx;
         m_dx = x;
         m_dy = y;
         
         if (m_y > 0)
         {
            m_y = 0;
         }
         else if (m_y < m_screenHeight - m_imageHeight)
         {
            m_y = m_screenHeight - m_imageHeight;
         }
         
         if (m_x > 0)
         {
            m_x = 0;
         }
         else if (m_x < m_screenWidth - m_imageWidth)
         {
            m_x = m_screenWidth - m_imageWidth;
         }
         repaint();
      }
   }
   /**
    * ʾ d ϵťc¼ 
    *  c ¼ť
    *  d ¼Ĳ
    */
   public void commandAction(Command c, Displayable d) 
   {
      if (c == ImageMove.EXIT)
      {
         m_repeat.done();
         m_repeat = null;
         m_appExiter.exitApp();
      }
   }
   /**
    * ģⰴظµĹ
    */
   class KeyRepeater extends Thread
   {
      private boolean m_done = false;
      private int m_gameAction;
      
      /**
       * ֹͣ߳
       */
      public synchronized void done()
      {
         m_done = true;
      }
      /**
       * ظһ
       *  keyCode ظİ
       */
      public synchronized void startRepeat(int keyCode)
      {
         m_gameAction = getGameAction(keyCode);
      }
      /**
       * ֹͣظ
       *  keyCode ظİ
       */
      public synchronized void stopRepeat(int keyCode)
      {
         if (getGameAction(keyCode) == m_gameAction)
         {
            m_gameAction = 0;
         }
      }
      /**
       * ظִй
       */
      public void run()
      {
         while (!m_done)
         {
            // ûҪظİ,һ߳
            while (m_gameAction == 0 && !m_done)
            {
               Thread.yield();
            }
            // ȴһСʱ
            synchronized (this)
            {
               try
               {
                  sleep(10);
               }
               catch (InterruptedException e)
               {
               }
            }
            // ִظİ
            moveImage(m_gameAction);
         }
      }
   }
}
/**
 * ûͨİť˳
 */
interface AppExiter
{
   /*
    * ʹEXITť˳
    */
   public static final Command EXIT = new Command("Exit", Command.EXIT, 1);
   /**
    * ˳
    */
   public void exitApp();
}
