CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Java >  J2ME

能不能给个用J2METM Wireless Toolkit做的小程序,现在一点都动不了呀,多谢了

楼主netapple(网络苹果)2002-04-15 19:02:26 在 Java / J2ME 提问

希望能有源程序,更主要的是怎么把这些程序加入到J2METM   Wireless   Toolkit中调试 问题点数:50、回复次数:3Top

1 楼jamsband(东子)回复于 2002-04-15 19:07:40 得分 25

我到是有两个,你发个mail给我吧,我的是jamsband@hotmail.com,我明天发给你Top

2 楼jax(阿杰)回复于 2002-04-16 14:18:16 得分 25

首先,j2mewtk只可以编译、运行、封装j2me程序,你先在ktoolbar中建立新工程,然后你必须用文本编辑器写好源代码,放入..\j2mewtk\apps\工程名\src目录下,在ktoolbar中点击Build,在下面的窗口中可以看到编译过程。  
   
  1:HelloWorld.java  
  import   javax.microedition.midlet.*;  
  import   javax.microedition.lcdui.*;  
   
  public   class   HelloWorld   extends   MIDlet   implements   CommandListener   {  
          private   Command   exitCommand;  
          private   TextBox   tb;  
   
          public   HelloWorld()   {  
                  exitCommand   =   new   Command("Exit",   Command.EXIT,   1);  
                  tb   =   new   TextBox("Hello   MIDlet",   "Hello,   World!",   15,   0);  
                  tb.addCommand(exitCommand);  
                  tb.setCommandListener(this);  
          }  
   
          protected   void   startApp()   {  
                  Display.getDisplay(this).setCurrent(tb);  
          }  
   
          protected   void   pauseApp()   {}  
          protected   void   destroyApp(boolean   u)   {}  
   
          public   void   commandAction(Command   c,   Displayable   d)   {  
                  if   (c   ==   exitCommand)   {  
                          destroyApp(false);  
                          notifyDestroyed();  
                  }  
          }  
  }  
   
   
  2:   TimerMIDlet.java  
   
  import   java.lang.*;  
  import   java.io.*;  
  import   java.util.*;  
   
  import   javax.microedition.lcdui.*;  
  import   javax.microedition.midlet.*;  
   
  /**  
    *   A   simple   class   that   shows   an   example   of   using   a   Timer   and  
    *   a   TimerTask.  
    *  
    *   This   MIDlet   creates   two   gauges.   One   gauge   gaugeOne,  
    *   sets   elements   from   low   to   high.   The   other,   gaugeTwo,  
    *   set   elements   from   high   to   low.   In   effect,   this   has  
    *   gaugeOne   "going   up",   and   gaugeTwo   "going   down."  
    *  
    *   The   two   timers   fire   at   different   intervals.  
    *  
    *   There   are   two   commands   on   our   form:  
    *    
    *   OK:   toggles   whether   the   times   are   active   or   not.  
    *   EXIT:   exits   the   MIDlet.  
    */  
   
  public   class   TimerMIDlet   extends   MIDlet   implements   CommandListener   {  
          //   number   of   elements   in   gauge  
          final   private   static   int   GAUGE_MAX   =   10;  
   
          private   boolean   timersRunning;   //   tracks   state   of   timers  
          private   Display   myDisplay;           //   handle   to   the   display  
   
          private   Gauge   gaugeOne;                 //   "going   up"   gauge  
          private   Gauge   gaugeTwo;                 //   "going   down"   gauge  
   
          private   Form   myScreen;                   //   form   on   which   to    
                                                                        //   place   gauges  
          private   Command   cmdOK;                   //   OK   command  
          private   Command   cmdExit;               //   EXIT   command  
   
          private   Timer   timer;  
          private   MyTimerTask   timerTaskOne;  
          private   MyTimerTask   timerTaskTwo;  
   
          /**  
            *   Internal   class   that   provides   a   TimerTask.  
            */  
          private   class   MyTimerTask   extends   TimerTask   {  
                  private   Gauge   myGauge;   //   reference   to   gauge  
                  private   boolean   goUp;     //   if   true,   go   up  
                  private   int   num;               //   number   of   times   called  
   
                  /**  
                    *   Public   constructor:   stores   "direction"   and   a   reference   to  
                    *   a   gauge.  
                    */  
                  public   MyTimerTask(Gauge   g,   boolean   up)   {  
                          myGauge   =   g;  
                          goUp   =   up;  
                  }  
   
                  /**  
                    *   As   the   timer   fires,   this   method   is   invoked.   Set   gauge  
                    *   based   on   goUp  
                    */  
                  public   void   run()   {  
                          num++;  
                          myGauge.setValue(goUp   ?  
                                                            GAUGE_MAX   -(num   %   GAUGE_MAX)   :  
                                                            num   %   GAUGE_MAX);  
                  }  
          }  
   
          /**  
            *   Public   constructor:   gets   handle   to   display,  
            *   creates   form,   gauges,   and   commands.  
            */  
          public   TimerMIDlet()   {  
                  myDisplay   =   Display.getDisplay(this);  
                  myScreen   =   new   Form("TimerMIDlet");  
                  gaugeOne   =   new   Gauge("Up   Gauge",  
                                                            false,  
                                                            GAUGE_MAX,  
                                                            0);  
                  myScreen.append(gaugeOne);  
   
                  gaugeTwo   =   new   Gauge("Down   Gauge",  
                                                            false,  
                                                            GAUGE_MAX,  
                                                            GAUGE_MAX);  
                  myScreen.append(gaugeTwo);  
   
                  cmdOK   =   new   Command("OK",   Command.OK,   1);  
                  cmdExit   =   new   Command("Exit",   Command.EXIT,   1);  
                  myScreen.addCommand(cmdOK);  
                  myScreen.addCommand(cmdExit);  
                  myScreen.setCommandListener(this);  
          }  
   
          /**  
            *   Changes   the   state   of   timers   to/from   active   to/from  
            *   not-active.  
            */  
          private   void   flipFlop()   {  
                  if   (timersRunning)   {  
                          timerTaskOne.cancel();  
                          timerTaskTwo.cancel();  
                          timer.cancel();  
                          timersRunning   =   false;  
                  }   else   {  
                          timer   =   new   Timer();  
                          timerTaskOne   =   new   MyTimerTask(gaugeOne,   false);  
                          timerTaskTwo   =   new   MyTimerTask(gaugeTwo,   true);  
                          timer.schedule(timerTaskOne,   0,   1000);  
                          timer.schedule(timerTaskTwo,   0,   1500);  
                          timersRunning   =   true;  
                  }  
          }  
   
          /**  
            *   Called   by   the   system   to   start   our   MIDlet.  
          *   @exception   MIDletStateChangeException  
            */  
          protected   void   startApp()   throws   MIDletStateChangeException   {  
                  myDisplay.setCurrent(myScreen);  
                  flipFlop();  
          }  
   
   
          /**  
            *   Called   by   the   system   to   pause   our   MIDlet.  
            *   No   actions   required   by   our   MIDLet.  
            */  
          protected   void   pauseApp()   {}  
   
          /**  
            *   Called   by   the   system   to   end   our   MIDlet.  
            *   No   actions   required   by   our   MIDLet.  
            */  
          protected   void   destroyApp(boolean   unconditional)   {}  
   
          /***  
            *   Respond   to   command   selections.   Process   two   commands:  
            *    
            *   OK:   flip   flop   the   timers   to/from   active  
            *   EXIT:   exit   this   MIDlet  
            *    
            */  
          public   void   commandAction(Command   c,   Displayable   d)   {  
                  if   (c   ==   cmdOK)   {  
                          flipFlop();  
                  }   else   if   (c   ==   cmdExit)   {  
                          destroyApp(false);  
                          notifyDestroyed();  
                  }  
          }  
  }  
   
   
  Top

3 楼dzy888(劈)回复于 2002-05-07 11:21:00 得分 0

gfgfTop

相关问题

  • 请帮忙,多谢,多谢!
  • 求助!多谢!!!
  • 多谢关照
  • 多谢指教……
  • To daiwoo,多谢
  • 多谢了!
  • 急!!多谢了!!!
  • 多谢LXFY
  • 求救CommonDialog的问题!多谢多谢!
  • 多谢winne_ll了!

关键词

  • j2me
  • j2
  • exitcommand
  • midlet
  • tb
  • microedition
  • helloworld
  • javax
  • command
  • import

得分解答快速导航

  • 帖主:netapple
  • jamsband
  • jax

相关链接

  • CSDN Java频道
  • Java类图书
  • Java类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo