首页 > 开发 > Java > 正文

我的J2ME编程联系(2)——DateField

2020-02-05 14:04:56
字体:
来源:转载
供稿:网友

  
/*
 * datefieldlet.java
 *
 * created on 2005年4月15日, 上午11:32
 */
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
 *
 * @author  administrator
 * @version
 */
public class datefieldlet extends midlet implements commandlistener{
    
    private form aform;
    private display adisplay;
    private datefield adatefield;
    private command exitcommand;
    private command okcommand;
    private alert analert;
    
    public datefieldlet(){
        
        analert=new alert("today",null,null,alerttype.info);
        analert.settimeout(3000);
                
        exitcommand=new command("exit",command.exit,1);
        okcommand=new command("ok",command.exit,1);
        
        aform=new form("datefieldtest");
        adatefield=new datefield("today’s date:",datefield.date_time);
        aform.append(adatefield);
        
        aform.addcommand(exitcommand);
        aform.addcommand(okcommand);
        aform.setcommandlistener(this);
    }
    
    public void startapp() {
        adisplay=display.getdisplay(this);
        adisplay.setcurrent(aform);
    }
    
    public void pauseapp() {
    }
    
    public void destroyapp(boolean unconditional) {
    }
    
    public void commandaction(command c,displayable d){
        //int i=0;
        string s="";
        
        if(c==exitcommand){
            destroyapp(false);
            notifydestroyed();
        }
        
        else{
            s=adatefield.getdate().tostring();
            analert.setstring(s);
            adisplay.setcurrent(analert,aform);
            
        }
    }
}
    
    
    
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表