课外天地 李树青学习天地JavaME移动开发课件 → 程序代码——DateField


  共有15271人关注过本帖树形打印复制链接

主题:程序代码——DateField

帅哥哟,离线,有人找我吗?
admin
  1楼 博客 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 管理员
等级:管理员 帖子:1949 积分:26803 威望:0 精华:34 注册:2003/12/30 16:34:32
程序代码——DateField  发帖心情 Post By:2008/9/25 10:06:34 [只看该作者]

import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemStateListener;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;

public class Exec extends MIDlet implements ItemStateListener {
        private Display display;

        public Exec() {
                display = Display.getDisplay(this);
        }

        TextField name;
        TextField tel;
        TextField summary;
        DateField date;

        public void startApp() {
                Form f = new Form("TextField 测试");
                name = new TextField("姓名", "", 8, TextField.ANY);
                tel = new TextField("电话", "", 14, TextField.PHONENUMBER);
                summary = new TextField("总结", "", 60, TextField.UNEDITABLE);
                date = new DateField("安排时间", DateField.DATE_TIME);
                f.append(name);
                f.append(tel);
                f.append(summary);
                f.append(date);
                f.setItemStateListener(this);
                display.setCurrent(f);
        }

        public void itemStateChanged(Item item) {
                if (item == name) {
                        summary.setString("输入的姓名为:" + name.getString());
                } else if (item == tel) {
                        summary.setString("输入的电话为:" + tel.getString());
                } else if (item == date) {
                        summary.setString("输入的时间为:" + date.getDate());
                } else {
                        summary.setString("");
                }
        }

        public void pauseApp() {
        }

        public void destroyApp(boolean unconditional) {
        }
}

[此贴子已经被作者于2010-12-12 18:31:16编辑过]

 回到顶部