DateFieldDemo.java
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:2k
源码类别:

J2ME

开发平台:

Java

  1. import javax.microedition.lcdui.*;
  2. import java.util.*;
  3. import javax.microedition.midlet.MIDlet;
  4. public class DateFieldDemo  extends MIDlet implements CommandListener
  5. {
  6.     private final static Command CMD_EXIT = new Command("Exit", Command.EXIT, 
  7.                                                         1);
  8.                                                      
  9.   //  private DateField item;
  10.     private Form mainForm;
  11.     
  12.     public DateFieldDemo() {
  13.         mainForm = new Form("DateField演示");
  14.     }                                                        
  15.                                                         
  16.     protected void startApp() {
  17.                 
  18.             /*    item = new DateField("Date", DateField.DATE);
  19.                 item.setDate(new Date());
  20.                 mainForm.append(item);
  21.              */   
  22.                 mainForm.append(new DateField("Date", DateField.DATE));
  23.                 mainForm.append(new DateField("Time", DateField.TIME));
  24.                 mainForm.append(
  25.         new DateField("Date & Time", DateField.DATE_TIME));
  26.                 mainForm.addCommand(CMD_EXIT);
  27.                 mainForm.setCommandListener(this);  
  28.                
  29.         Display.getDisplay(this).setCurrent(mainForm);
  30.     }    
  31.     protected void destroyApp(boolean unconditional) {
  32.     }    
  33.     protected void pauseApp() {
  34.     }   
  35.     
  36.     public void commandAction(Command c, Displayable d) {
  37.         if (c == CMD_EXIT) {
  38.             destroyApp(false);
  39.             notifyDestroyed();
  40.         }
  41.     }    
  42. }