大家帮我看这段代码的错误~~小弟刚入行!!在线等

leilei0622 2006-03-15 11:16:30
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public abstract class SkeletonMIDlet extends MIDlet implements CommandListener {

private SCanvas canvas;;




//public SkeletonMIDlet() {
// super();

//}


public void startApp() throws MIDletStateChangeException {

if(canvas == null){

canvas = new SCanvas(Display.getDisplay(this));
Command exitCommand = new Command("退出",Command.EXIT,0);
canvas.addCommand(exitCommand);
canvas.setCommandListener(this);
}

canvas.start();

}


protected void pauseApp() {


}


protected void destroyApp(boolean arg0) throws MIDletStateChangeException {


}

public void commandAction(Command c,Display s) {


if(c.getCommandType() == Command.EXIT){
try {
destroyApp(true);
} catch (MIDletStateChangeException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
notifyDestroyed();
}
}
}
...全文
75 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
fengchenxiuji 2006-03-16
此例子错误比较多,现在我一次性修改如下,如有问题请到我的QQ群详谈:1407603

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class SkeletonMidlet extends MIDlet implements CommandListener {

private MyCanvas canvas;

public void startApp() throws MIDletStateChangeException
{

if(canvas == null){

canvas = new MyCanvas();
Display.getDisplay(this).setCurrent (canvas);
Command exitCommand = new Command("退出",Command.EXIT,0);
canvas.addCommand(exitCommand);
canvas.setCommandListener(this);
}
}


protected void pauseApp()
{
}

protected void destroyApp(boolean arg0) throws MIDletStateChangeException
{
}

public void commandAction(Command c,Displayable s)
{
if(c.getCommandType() == Command.EXIT)
{
try
{
destroyApp(true);
}
catch (MIDletStateChangeException e)
{
e.printStackTrace();
}
notifyDestroyed();
}
}
}

class MyCanvas extends Canvas
{
public void paint(Graphics g)
{
g.fillRect (0,0, getWidth(),getHeight());
}
}
回复
相关推荐
发帖
J2ME
创建于2007-09-28

1.3w+

社区成员

Java J2ME
申请成为版主
帖子事件
创建了帖子
2006-03-15 11:16
社区公告
暂无公告