分析MIDP的高级事件处理机制[2]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

    public void init()
    {
       
        inputField = new TextField("Input", null, 25, TextField.ANY);
        inputField2 = new TextField("Input2", null, 25, TextField.ANY);
        choice = new ChoiceGroup("click", Choice.MULTIPLE);
        choice.append("Another", null);
        this.append(inputField);
        this.append(choice);
        this.addCommand(cmd);
        this.setCommandListener(this);
        this.setItemStateListener(this);

    }

 
    public void commandAction(Command arg0, Displayable arg1)
    {
        if(arg0 == cmd)
        {
            String input = inputField.getString();
            System.out.println(input);
            midlet.getDisplayUI().setInput(input);
            midlet.getDisplay().setCurrent(midlet.getDisplayUI());
           
        }

    }

 
    public void itemStateChanged(Item arg0)
    {
       
        if(arg0 == choice)
        {
           
            if(choice.isSelected(0) == true)
            {
                index = this.append(inputField2);
            }
            else
            {
                this.delete(index);
            }
        }

    }

}

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;


public class DisplayUI extends Form implements CommandListener
{

    private HighLevelMIDlet midlet;
    private StringItem displayItem;
    private Displayable backUI;
    public static final Command backCommand = new Command("Back", Command.BACK,
            2);

    public DisplayUI(HighLevelMIDlet midlet,Displayable backUI)
    {
        super("Display");
        this.midlet = midlet;
        this.backUI = backUI;
        init();
        this.addCommand(backCommand);
        this.setCommandListener(this);
    }

本文关键:分析MIDP的高级事件处理机制
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top