首 页文章中心下载中心繁體中文
设为首页
加入收藏
联系我们
您当前的位置:开源盛世-源代码下载网 -> 文章中心 -> 其他编程 -> Java技术 -> 文章内容 退出登录 用户管理
栏目导航
· VC# 技术 · Delphi技术
· Java技术 · 通用算法
· 编程相关
热门文章
· Tab Control控件使用...
· 学生档案管理系统
· [图文] 排列组合公式
· UTF-8与GB2312之间的...
· DirectShow下载安装...
· Virtual PC 在PAE模...
· Windows2000终端服务...
· MapInfo上的GIS系统...
· kalman filter 卡尔...
· Windows2000终端服务...
相关文章
· Sample code for us...
· 关于Delphi中预编译...
Using the calendar -- j2me 中 Datefield的使用方法
作者:佚名  来源:vscodes.com整理  发布时间:2005-12-16 12:57:30  发布人:Polaris

减小字体 增大字体

前言:Datefield 是j2me中一个显示日历的可视组件,
这篇文章讲的视Datefield 事件触发的处理,通过
itemStateChanged方法实现,推荐给大家

Using the calendar

answered by Eric Giguere, author of Sun''s J2ME Tech Tips
In this example a DateField object is created and added to a form. When you click on the date, you can change it by navigating through the calendar. When the date is changed, a message appears. Example described in the "MIDP Event Handling" article. (EventEx2.java)

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class EventEx2 extends MIDlet {
    Display display;

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

    public void destroyApp (boolean unconditional) {
        notifyDestroyed();
        System.out.println("App destroyed ");
    }

    public void pauseApp () {
        display = null;
        System.out.println("App paused.");
    }

    public void startApp () {
        Form form = new Form("Change Date");
        
        ItemStateListener listener = new ItemStateListener() {
            java.util.Calendar cal =
              java.util.Calendar.getInstance(java.util.TimeZone.getDefault());

            public void itemStateChanged(Item item) {
                cal.setTime(((DateField)item).getDate());
                System.out.println("\nDate has changed");
            }
        };

        // register for events
        form.setItemStateListener(listener);
        
        // get today''s date
        java.util.Date now = new java.util.Date();
        DateField dateItem = new DateField("Today''s date:", DateField.DATE);
        dateItem.setDate(now);
        // add date to the Form screen
        form.append(dateItem);
        display.setCurrent(form);
    }
}
 

End of《Using the calendar -- j2me 中 Datefield的使用方法》

[] [返回上一页] [打 印] [收 藏]
 
∷相关“Using the calendar -- j2me 中 Datefield的使用方法”文章评论∷
(评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 网站目录 鄂ICP备06007162
开源盛世 版权所有Copyright © 2003-2005 VSCodes.Com. All Rights Reserved.