日期:2014-05-20  浏览次数:20805 次

帮忙看段程序
//书上的,但是我用wtk2.3运行后得不出应该的结果。应该是一开始点退出consule里会打印出因为unconditional为false的异常吧,然后再点一次才正常退出。
大家试试是什么结果
我怀疑wtk有问题。。特别是异常处理的问题

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

/**
  *   A   MIDlet   which   demonstrates   the   lifecycle   of   a   MIDlet
  *   @author   Martin   J.   Wells
  */
public   class   LifecycleTest   extends   javax.microedition.midlet.MIDlet
                  implements   CommandListener
{
      private   Form   form;
      private   Command   quit;
      private   boolean   forceExit   =   false;

      /**
        *   Constructor   for   the   MIDlet   which   creates   a   simple   Form,   adds   some   text   and
        *   an   exit   command.   When   called   this   method   will   also   write   a   message   to   the
        *   console.   This   is   used   to   demonstrate   the   sequence   of   events   in   a   MIDlet 's
        *   lifecycle.
        */
      public   LifecycleTest()
      {
            System.out.println( "Constructor   called. ");

            form   =   new   Form( "Life,   Jim. ");
            form.append( "But   not   as   we   know   it. ");
            form.setCommandListener(this);

            //   Create   and   add   two   commands   to   change   the   MIDlet   state  
            quit   =   new   Command( "Quit ",   Command.SCREEN,   1);
            form.addCommand(quit);
      }

      /**
        *   Called   by   the   Application   Manager   when   the   MIDlet   is   starting   or   resuming
        *   after   being   paused.   In   this   example   it   acquires   the   current   Display   object
        *   and   uses   it   to   set   the   Form   object   created   in   the   MIDlet   constructor   as

        *   the   active   Screen   to   display.   Also   displays   a   message   on   the   console   when
        *   called   to   demonstrate   when   this   method   is   called   in   the   MIDlet   lifecycle.
        *   @throws   MIDletStateChangeException
        */
      protected   void   startApp()   throws   MIDletStateChangeException
      {