j2me datefield.txt

来自「J2ME里面的DateField简单运用 实现简单日历开发」· 文本 代码 · 共 43 行

TXT
43
字号

import javax.microedition.midlet.*; 
import javax.microedition.lcdui.*; 
 
public class SimpleCalendar extends MIDlet implements CommandListener, ItemStateListener { 
    private Form mainForm; 
    private DateField nameDateField; 
    public SimpleCalendar() { 
        mainForm = new Form("简单日历"); 
        nameDateField = new DateField("日期", DateField.DATE_TIME); 
    } 
    protected void startApp() throws MIDletStateChangeException { 
        mainForm.append(nameDateField); 
        mainForm.addCommand( new Command("退出", Command.EXIT, 1)); 
        mainForm.setItemStateListener(this); 
        mainForm.setCommandListener(this); 
        Display.getDisplay(this).setCurrent(mainForm); 
    } 

    protected void pauseApp() { 
    } 

    protected void destroyApp(boolean _boolean) throws 
            MIDletStateChangeException { 
    } 

    public void commandAction(Command command, Displayable displayable) { 
        if(command.getCommandType() == Command.EXIT) { 
            try { 
               destroyApp(false); 
            } catch (MIDletStateChangeException e) { 
                e.printStackTrace(); 
            } 
            notifyDestroyed(); 
        } 
    } 

    public void itemStateChanged(Item item) { 
    } 
} 
	
	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?