编程
/*
* 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);
}
}
}
我的J2ME编程联系(2)——DateField
80酷酷网 80kuku.com