MULTIPLEChoiceGroupDemo.java
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:

J2ME

开发平台:

Java

  1. import javax.microedition.lcdui.*;
  2. import javax.microedition.midlet.MIDlet;
  3. public class MULTIPLEChoiceGroupDemo
  4.     extends MIDlet implements CommandListener {
  5.     private final static Command CMD_EXIT = new Command("Exit", Command.EXIT, 
  6.                                                         1);        
  7.     private Display display;
  8.     private ChoiceGroup mChoiceGroup;
  9.     private Form mainForm;
  10.     public MULTIPLEChoiceGroupDemo() {
  11.        display = Display.getDisplay(this);
  12.        mainForm = new Form("Choice Group演示");
  13.        Image[] imageArray = null;
  14.        try {
  15.                 Image star = Image.createImage("/star.png");
  16.                 imageArray = new Image[] { star, star, star, star, star, star};
  17.        } catch (java.io.IOException err) {
  18.        }
  19.        String[] stringArray = {
  20.                 "红心大战","空当接龙","三维弹球","蜘蛛纸牌","翻转棋","扫雷"
  21.             };
  22.        mChoiceGroup = new ChoiceGroup("选择游戏项目",ChoiceGroup.MULTIPLE,stringArray,imageArray);
  23.        mainForm.append(mChoiceGroup);
  24.        mainForm.addCommand(CMD_EXIT);
  25.        mainForm.setCommandListener(this);
  26.     }
  27.     protected void startApp() {        
  28.         display.setCurrent(mainForm);
  29.     }
  30.     public void commandAction(Command c, Displayable d) {
  31.         if (c == CMD_EXIT) {
  32.             destroyApp(false);
  33.             notifyDestroyed();
  34.         }
  35.     }
  36.     protected void destroyApp(boolean unconditional) {
  37.     }
  38.     protected void pauseApp() {
  39.     }
  40. }