石頭JAVA擺地攤兒

          JAVA所有的討論-要一點一點的進步

            BlogJava :: 首頁 ::  :: 聯系 ::  :: 管理 ::
            30 隨筆 :: 0 文章 :: 11 評論 :: 0 Trackbacks

           留個紀念:

          package j2me;

          import
           java.io.IOException;

          import
           javax.microedition.lcdui.Choice;
          import
           javax.microedition.lcdui.Command;
          import
           javax.microedition.lcdui.CommandListener;
          import
           javax.microedition.lcdui.Display;
          import
           javax.microedition.lcdui.Displayable;
          import
           javax.microedition.lcdui.Image;
          import
           javax.microedition.lcdui.List;
          import
           javax.microedition.midlet.MIDlet;
          import
           javax.microedition.midlet.MIDletStateChangeException;

          public class j2me1 extends MIDlet implements
           CommandListener {

              Display display 
          = null
          ;

              
          public
           j2me1() {
                  
          // TODO Auto-generated constructor stub

              }

              
          protected void destroyApp(boolean arg0) throws
           MIDletStateChangeException {
                  
          // TODO Auto-generated method stub


              }

              
          protected void pauseApp() {
                  
          // TODO Auto-generated method stub


              }

              
          protected void startApp() throws MIDletStateChangeException {
                  display 
          = Display.getDisplay(this
          );
                  Image img 
          = null
          ;
                  
          //
           Form form = new Form("標題");
                  
          //
           form.setTicker(new Ticker("我的ticker"));
                  
          //
           form.addCommand(new Command("提交", "提交長", Command.OK, 1));
                  
          //
           form.addCommand(new Command("取消", "取消長", Command.BACK, 1));
                  
          // form.setCommandListener(new j2me1_commandlistener_impl());

                  try {
                      img 
          = Image.createImage("/res/new.PNG"
          );
                  } 
          catch
           (IOException e) {
                      
          // TODO Auto-generated catch block

                      e.printStackTrace();
                  }

                  List list 
          = new List("ghyghost's list"
          , Choice.MULTIPLE);
                  list.append(
          "1"
          , img);
                  list.append(
          "2"
          , img);
                  list.append(
          "3"
          , img);
                  list.append(
          "4"
          , img);

                  list.setSelectedIndex(
          2true
          );

                  list.addCommand(
          new Command("提交""提交長", Command.OK, 1
          ));
                  list.setCommandListener(
          this
          );

                  display.setCurrent(list);
              }

              
          public void
           commandAction(Command command, Displayable displayable) {
                  
          if (command ==
           List.SELECT_COMMAND) {
                      System.out.println(
          "c == List.SELECT_COMMAND"
          );
                      System.out.println(command.getLabel());
                      System.out.println(
          "index ="

                              
          + ((List) displayable).getSelectedIndex());
                      System.out.println(
          "String ="

                              
          + ((List) displayable).getString(((List) displayable)
                                      .getSelectedIndex()));
                  } 
          else
           {
                      System.out.println(
          "button click"
          );
                      System.out.println(
          "button name is:" +
           command.getLabel());
                      System.out.println(command.getLabel());
                      System.out.println(
          "index ="

                              
          + ((List) displayable).getSelectedIndex());
                      System.out.println(
          "String ="

                              
          + ((List) displayable).getString(((List) displayable)
                                      .getSelectedIndex()));
                  }
              }
          }
          posted on 2008-06-18 18:56 石頭JAVA擺地攤兒 閱讀(747) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 碌曲县| 灌南县| 临澧县| 沙坪坝区| 元氏县| 富阳市| 杭锦后旗| 灵璧县| 库车县| 洛南县| 遂溪县| 三河市| 平昌县| 全椒县| 青海省| 许昌县| 博野县| 当涂县| 红河县| 台湾省| 连江县| 洞口县| 林周县| 西和县| 廊坊市| 前郭尔| 阳原县| 文水县| 青阳县| 五莲县| 云梦县| 洛阳市| 虞城县| 滁州市| 穆棱市| 介休市| 庆城县| 夏邑县| 玉龙| 邹平县| 偏关县|