书上找不到答案了,自己写了一个例子
JDK1.6+WT2.5.2调试,不报错,不显示东西
大家帮我看看为什么吧
代码在下面:
-==============================
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class DrawStringTest extends MIDlet implements CommandListener{
private Command quit;
private Command doit;
private MyCanvas mycanvas;
class MyCanvas extends Canvas{
protected void paint(Graphics graphics) {
graphics.setColor(100,100,255);
graphics.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.SIZE_LARGE,Font.STYLE_BOLD));
graphics.drawString("show me the money", 15, 15, Graphics.TOP|Graphics.LEFT);
}
}
public void DrawStringTest() {
mycanvas=new MyCanvas();
quit=new Command("Quit",Command.EXIT,1);
mycanvas.addCommand(quit);
doit=new Command("Doit",Command.OK,2);
mycanvas.addCommand(doit);
mycanvas.setCommandListener(this);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(mycanvas);
}
public void commandAction(Command command, Displayable displayable) {
try{
if(command==quit){
destroyApp(true);
notifyDestroyed();
}
if(command==doit){
mycanvas.repaint();
}
}catch(MIDletStateChangeException me){}
}
}
谢谢
------解决方案--------------------------------------------------------