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);
}