一个例程不明白为什么?求教!

new_j2me new_j2me 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这是我调的一个程序,几个问题请教一下。
import java.util.Calendar;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
*
* @author jn27
* @version
*/
public class SimpleGraphic extends MIDlet implements CommandListener{
private Command exitCommand;
private SimpleGraphicCanvas sg;

public SimpleGraphic(){
exitCommand=new Command("Exit",Command.EXIT, 1);
sg=new SimpleGraphicCanvas();
sg.addCommand(exitCommand);
sg.setCommandListener(this);
Display.getDisplay(this).setCurrent(sg);
}
public void startApp() {
}

public void pauseApp() {
}

public void destroyApp(boolean arg0) {
}

public void commandAction(Command c,Display d){//为何这里报错说SimpleGraphic是个抽象类,不能覆写commandAction()?我明明是继承了接口CommandListener啊?
if(c==exitCommand){
destroyApp(false);//为何这里报错??
notifyDestroyed();
}
}
}
class SimpleGraphicCanvas extends Canvas{
protected void paint(Graphics g){
g.drawLine(0,0, 50,50);
g.drawRect(60,60, 50, 80);
g.fillRect(65,65, 30,40);
}
}
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
new_j2me
J2ME 13,096 成员 26,491 内容