package pro4;
import java.io.IOException;
import java.util.Date;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
public class item extends MIDlet implements CommandListener{
private Form f=new Form("ITEM演示");
//private Form f2=new Form("图片演示");
private Display dis;
private ChoiceGroup cg=new ChoiceGroup("单选",ChoiceGroup.EXCLUSIVE); //选项
private ChoiceGroup cg2=new ChoiceGroup("下拉",ChoiceGroup.POPUP);
private ChoiceGroup cg3=new ChoiceGroup("多选",ChoiceGroup.MULTIPLE);
private DateField df=new DateField("时间",DateField.DATE_TIME); //时间选项,比较实用
private Gauge ga=new Gauge("音量",true,10,1); //可手动修改的进度条
private Gauge ga1=new Gauge("文件进度",false,40000,1); //不可手动修改的进度条
private ImageItem imit;
private TextField tf=new TextField("姓名", "", 6, TextField.ANY); //必须在form中使用,任意类型
private TextField tf2=new TextField("身份证号", "", 20, TextField.NUMERIC); //限制为数字
private TextField tf3=new TextField("密码", "", 20, TextField.PASSWORD); //密码框
private StringItem strit=new StringItem("title1", "PLAIN",Item.PLAIN); //普通样式
private StringItem strit2=new StringItem("title2", "BUTTON",Item.BUTTON); //按钮样式
private StringItem strit3=new StringItem("title3", "HYPERLINK",Item.HYPERLINK); //超链接样式
Image img=null;
public item() throws IOException {
// TODO Auto-generated constructor stub
try {
img = Image.createImage("/25.png");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imit=new ImageItem("显示图片",img,ImageItem.LAYOUT_CENTER|Item.LAYOUT_EXPAND,"加载失败");
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
dis=Display.getDisplay(this);
dis.setCurrent(f);
f.append(cg);
cg.append("男",null);
cg.append("女", null);
f.append(cg2);
cg2.append("男", null);
cg2.append("女", null);
f.append(cg3);
cg3.append("打架", null);
cg3.append("骂人",null);
dis.setCurrentItem(cg3);
f.append(df);
df.setDate(new Date());
f.append(ga);
ga.setValue(6); //设置默认值
f.append(imit);
f.append(tf);
f.append(tf2);
f.append(tf3);
f.append(ga1);
/*while(true)
{
ga1.setValue(ga1.getValue()+1);
if(ga1.getValue()==ga1.getMaxValue())
break;
}*/
f.append(strit);
f.append(strit2);
f.append(strit3);
strit2.addCommand(new Command("",Command.ITEM , 1));
strit3.addCommand(new Command("",Command.ITEM , 1));
}
public void commandAction(Command arg0, Displayable arg1) {
// TODO Auto-generated method stub
}
}