于是动手:
开发工具:
NetBeans
1,必须先建个项目(我开发那么久的WEB,做手机开发时竟然给忘记了)
/*
* Midlet.java
*
* Created on 2006年4月26日, 下午6:07
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
*
* @author hero
* @version
*/
public class Hello extends MIDlet implements CommandListener
{
private Display display;
private Command exitcommand;
private TextBox tb;
public Hello()//构造函数,记得要和类名一样,同时要命名时也一样,如Hello.java
{
display=Display.getDisplay(this);//注意要找到已经定义的变量用Ctrl+K,OK!
exitcommand=new Command("Exit",Command.BACK,1);
tb=new TextBox("Hello Evryone!","Hello Evryone",256,0);
tb.addCommand(exitcommand);
tb.setCommandListener(this);
display.setCurrent(tb);
}
public void startApp()
{
//如果不写构造函数的话,则必须在这此调用,否则无法运行,如Hello();
display.setCurrent(tb);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c,Displayable d)
{
if(c==exitcommand)
{
destroyApp(false);
notifyDestroyed();
}
}
}
* Midlet.java
*
* Created on 2006年4月26日, 下午6:07
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
*
* @author hero
* @version
*/
public class Hello extends MIDlet implements CommandListener
{
private Display display;
private Command exitcommand;
private TextBox tb;
public Hello()//构造函数,记得要和类名一样,同时要命名时也一样,如Hello.java
{
display=Display.getDisplay(this);//注意要找到已经定义的变量用Ctrl+K,OK!
exitcommand=new Command("Exit",Command.BACK,1);
tb=new TextBox("Hello Evryone!","Hello Evryone",256,0);
tb.addCommand(exitcommand);
tb.setCommandListener(this);
display.setCurrent(tb);
}
public void startApp()
{
//如果不写构造函数的话,则必须在这此调用,否则无法运行,如Hello();
display.setCurrent(tb);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c,Displayable d)
{
if(c==exitcommand)
{
destroyApp(false);
notifyDestroyed();
}
}
}
2,F5一下,一切就搞定了!