張生工作室

          一切皆有可能

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            24 隨筆 :: 3 文章 :: 11 評論 :: 0 Trackbacks

          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.lcdui.Item;
          import javax.microedition.lcdui.ItemCommandListener;
          import javax.microedition.lcdui.ItemStateListener;
          import javax.microedition.lcdui.TextField;
          import javax.microedition.midlet.MIDlet;
          import javax.microedition.midlet.MIDletStateChangeException;

          public class MIDletItemCommmandListener extends MIDlet implements ItemCommandListener,CommandListener,ItemStateListener {
                                                                        
           
           private Form frm=new Form("Item監(jiān)聽器");
           private TextField uid=new TextField("用戶名","",20,TextField.ANY);
           private TextField pwd=new TextField("密碼","",20,TextField.PASSWORD);
           private Display dis=Display.getDisplay(this);
           private Command Del=new Command("刪除",Command.ITEM,1);
           
           public MIDletItemCommmandListener() {
            
           }

           protected void startApp() throws MIDletStateChangeException {
            
            
            
            frm.append(uid);
            uid.addCommand(Del);
            pwd.addCommand(Del);
            pwd.setItemCommandListener(this);
            uid.setItemCommandListener(this);
            frm.append(pwd);
            dis.setCurrent(frm);
            dis.setCurrentItem(pwd);
            frm.setItemStateListener(this);
            


           }
           
           protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
           

           }

           protected void pauseApp() {
            

           }

           public void commandAction(Command c, Item i) {
            
            if(c==Del)
            {
             TextField tf=(TextField)i;
             
             int p=tf.getCaretPosition();
             if(p>0)
             {
             tf.delete(p-1, 1);
             }
            }
           
            
           }

           public void commandAction(Command c, Displayable d) {
            
            
           }

           public void itemStateChanged(Item i) {
            
              if(i==uid)
              {
               frm.setTitle("用戶名"+uid.getString());
              } else if(i==pwd)
              {
               frm.setTitle("密碼"+uid.getString());
              }
            
           }

           

          }



          張生工作室
          posted on 2008-11-27 08:49 張生工作室 閱讀(418) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網站導航:
           
          主站蜘蛛池模板: 大宁县| 藁城市| 浙江省| 中方县| 庆云县| 汾阳市| 云安县| 铜川市| 饶阳县| 枞阳县| 日喀则市| 霞浦县| 巫山县| 马龙县| 陇南市| 安西县| 奇台县| 文化| 金昌市| 铜川市| 佛冈县| 南丰县| 塔河县| 酒泉市| 固始县| 曲阳县| 鹤庆县| 深州市| 府谷县| 许昌县| 盱眙县| 尼玛县| 花莲市| 临邑县| 泸水县| 渭源县| 康乐县| 马关县| 宾川县| 毕节市| 城固县|