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

J2ME

开发平台:

Java

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