【Java开源代码栏目提醒】:本文主要为网学会员提供helloworldMIDlet.java,希望对需要helloworldMIDlet.java网友有所帮助,学习一下!
import javax.microedition.rms.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
public class helloworldMIDlet extends MIDlet implements CommandListener
{
private Command exitCommand;
private Command doneCommand;
private Command infoCommand;
private Display display;
private javax.microedition.lcdui.TextBox hello = null;
private javax.microedition.lcdui.TextBox info = null;
public helloworldMIDlet()
{
exitCommand = new Command("Exit",Command.EXIT,1);
doneCommand = new Command("Done",Command.OK,2);
infoCommand = new Command("Info",Command.OK,2);
}
public void startApp()
{
hello = new javax.microedition.lcdui.TextBox("Hello World Demo","HelloWorld from J2ME MIDP!",40,0);
hello.addCommand(exitCommand);
hello.addCommand(infoCommand);
hello.setCommandListener(this);
display.setCurrent(hello);
info = new javax.microedition.lcdui.TextBox("Info fro Hello World Demo","This is the HelloWorld MIDlet",40,0);
info.addCommand(exitCommand);
info.setCommandListener(this);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c,Displayable s)
{
if(c==exitCommand)
{
destroyApp(false);
notifyDestroyed();
}
else if(c==doneCommand)
{
display.setCurrent(hello);
}
else if(c==infoCommand)
{
display.setCurrent(info);
}
}
};
上一篇:
HelloWorldHttpServlet.java
下一篇:
盘点士兵的各种搞笑失误,连老纳都笑了!