⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 choicegroupdemo.java

📁 J2ME MIDP 2.0 无线设备编程的一些源码
💻 JAVA
字号:
//choiceGroupDemo.java file
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import itemex.*;

public class choiceGroupDemo extends MIDlet implements CommandListener, ItemStateListener
{
    private Command exitCommand;
    private PopupChoiceGroup cgPopup;
    private String[] stringArray;
    private TextField textId;
    private Form form;
    public choiceGroupDemo()
    {
        String[] stringArray = {"身份证","军人证"};
        exitCommand =new Command("Exit",Command.EXIT,1);
        //创建POPUP模式的列表框
        cgPopup = new PopupChoiceGroup("证件选择", stringArray, null);
        cgPopup.setSelectedIndex(0, true);
        //创建输入证件号码的输入框
        textId = new TextField("身份证号码", "", 20, TextField.NUMERIC);
        //创建Form对象,并添加Item 对象
        form = new Form("PopupChoiceGroup Demo");
        form.append(new StringItem("证 件 输 入"," "));
        form.get(0).setLayout(Item.LAYOUT_CENTER| Item.LAYOUT_2| Item.LAYOUT_EXPAND);
        form.append(cgPopup);
        form.append(textId);
        //添加Form 对象的命令
        form.addCommand(exitCommand);
        form.setCommandListener(this);
        form.setItemStateListener(this);
    }
    protected void startApp(  ) throws MIDletStateChangeException
    {
        Display.getDisplay(this).setCurrent(form);
    }

    protected void pauseApp(  )
    {
    }

    protected void destroyApp( boolean p1 )
    {
    }

    public void commandAction(Command c,Displayable d)
    {
        if (c ==exitCommand)
        {
            destroyApp(false);
            notifyDestroyed();
        }
    }

    public void itemStateChanged(Item item)
    {//处理选择框内选项改变的事件
        if( item instanceof PopupChoiceGroup)
        {
            textId.setLabel( cgPopup.getString(cgPopup.getSelectedIndex())+"号码" );
        }
    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -