双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

关于repaint()方法调用问题

chenzujie chenzujie 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
小弟我自己新建一个Canvas类:
public class DemoCanvas extends Canvas
{
private String textShow="主界面";
public DemoCanvas()
{
this.setTitle(textShow);
}
public void paint(Graphics g)
{
g.setColor(0xffffff);
g.fillRect(0, 0,getWidth(),getHeight());
g.drawImage(imageBook[page], 0, 0, Graphics.TOP|Graphics.LEFT);
}
protected void keyPressed(int keyCode){
if(getGameAction(keyCode)==RIGHT){
if(page==0)

page++;
if(page<14)
this.setTitle("小猪发脾气");
repaint();
}
}
想要在主Midlet类中
else if(Command.OK==c.getCommandType())
{
int i=listmenu.getSelectedIndex();
page=i;
myCanvas.repaint();//myCanvas是DemoCanvas型变量
}调用repaint(),但却不会显示调用,我想知道为什么啊?
...全文
评论 15
收藏 已收藏
分享
返回顶部
chenzujie
chenzujie 领域专家: 操作系统技术领域 领域专家: 操作系统技术领域
J2ME 13,096 成员 26,491 内容