rendered paste body//package textfield;
package stringitem;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class assignment1 extends MIDlet implements CommandListener, ItemCommandListener
{
private Display display;
private Form mainForm,Form2,Form3;
private Command CMD_EXIT=new Command("Exit",Command.EXIT,1);
private Command CMD_BACK=new Command("Back",Command.BACK,1);
private Command CMD_SHOW = new Command("next",Command.SCREEN,1);
// private Command hola = new Command("hola",Command.SCREEN,2);
private Command CMD_NEXT=new Command("show",Command.ITEM,1);
StringItem str=new StringItem("this is string","this is the text..");
StringItem hyperstr=new StringItem("hyper-string","where to click but..",Item.HYPERLINK);
TextField t1;
public assignment1()
{
display=Display.getDisplay(this);
str=new StringItem("this is string","this is the text..");
}
protected void startApp()
{
mainForm = new Form("form lable ahey hey");
mainForm.append("Select a text box type");
// mainForm.append(str);
mainForm.append (hyperstr);
hyperstr.setDefaultCommand(CMD_NEXT);
mainForm.addCommand(CMD_EXIT);
Form2=new Form("form 2");
Form2.addCommand(CMD_SHOW);
Form2.addCommand(CMD_EXIT);
Form2.append(str);
str=new StringItem("press","button",Item.BUTTON);
str.setDefaultCommand(CMD_SHOW);
Form2.append(str);
Form3=new Form("form 3");
Form3.addCommand(CMD_EXIT);
// t1=new TextField("name","",15,TextField.ANY);
Form3.append(new TextField("name","",15,TextField.ANY));
// t1=new TextField("number","",15,TextField.NUMERIC);
Form3.append(new TextField("number","",15,TextField.NUMERIC));
mainForm.setCommandListener(this);
hyperstr.setItemCommandListener(this);
display.setCurrent(mainForm);
}
protected void destroyApp(boolean unconditional)
{}
protected void pauseApp()
{}
public void commandAction(Command c , Displayable d)
{
if(c==CMD_EXIT)
{
destroyApp(false);
notifyDestroyed();
}
if(c==CMD_BACK)
{
str.setItemCommandListener(this);
Form2.setCommandListener(this);
display.setCurrent(Form2);
}
}
public void commandAction(Command c, Item item)
{
if(c==CMD_NEXT)
{
Form2.setCommandListener(this);
display.setCurrent(Form2);
str.setItemCommandListener(this);
}
if(c==CMD_SHOW)
{
Form3.setCommandListener(this);
display.setCurrent(Form3);
}
}
}