`
qiufengxiaose
  • 浏览: 6814 次
  • 性别: Icon_minigender_1
  • 来自: 成都
最近访客 更多访客>>
社区版块
存档分类
最新评论

我的第一个javaME程序(一个电话日历应用程序)

阅读更多
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;

//A first MIDlet with simple text and a few commands.
public class PhoneCalendar extends MIDlet implements CommandListener, ItemStateListener {

//The commands
private Command exitCommand;

//The display for this MIDlet
private Display display;

// Display items e.g Form and DateField
Form displayForm;
DateField date;

public PhoneCalendar() {
	  display = Display.getDisplay(this);
	  exitCommand = new Command("Exit", Command.SCREEN, 1);
	  date = new DateField("Select to date", DateField.DATE);
	  
}

// Start the MIDlet by creating the Form and 
// associating the exit command and listener.
public void startApp() {
	displayForm = new Form("Quick Calendar");
	displayForm.append(date);
	displayForm.addCommand(exitCommand);
	displayForm.setCommandListener(this);
	displayForm.setItemStateListener(this);
	display.setCurrent(displayForm);
}

public  void itemStateChanged(Item item)
{
 // Get the values from changed item
}

// Pause is a no-op when there is no  background
// activities or record stores to be closed.
public void pauseApp() { }

// Destroy must cleanup everything not handled 
// by the garbage collector.
public void destroyApp (boolean unconditional) { }

// Respond to commands. Here we are only implementing
// the exit command. In the exit command, cleanup and
// notify that the MIDlet has been destroyed.
public void commandAction (Command c, Displayable s) 
{
	if (c == exitCommand) 
	{
		destroyApp(false);
		notifyDestroyed();
	}
}
}

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics