public void paint(Graphics g){
//清除屏幕
int color = g.getColor();
g.setColor(0xFFFFFF);
g.fillRect(0,0,getWidth(),getHeight());
g.setColor(color);
//计算整个菜单的高度,宽度和(x,y)
int rectWidth = preferWidth;
int rectHeight = preferHeight * LABELS.length;
int x = (getWidth()-rectWidth)/2;
int y = (getHeight()-rectHeight)/2;
//画矩形
g.drawRect(x,y,rectWidth,rectHeight);
for(int i = 1;i<LABELS.length;i++){
g.drawLine(x,y+preferHeight*i,x+rectWidth,y+preferHeight*i);
}
//画菜单选项,并根据selected的值判断焦点
for(int j = 0;j<LABELS.length;j++){
if(selected == j){
g.setColor(0x6699cc);
g.fillRect(x+1,y+j*preferHeight+1,rectWidth-1,preferHeight-1);
g.setColor(color);
}
g.drawString(LABELS[j],x+8,y+j*preferHeight+4,Graphics.LEFT|Graphics.TOP);
}
}请高手帮忙看看上面的代码,编译时说找不到符号 符号: 方法 getWidth()
位置: 类 MenuCanvas
g.fillRect(0,0,getWidth(),getHeight());
怎么会这样啊???
//清除屏幕
int color = g.getColor();
g.setColor(0xFFFFFF);
g.fillRect(0,0,getWidth(),getHeight());
g.setColor(color);
//计算整个菜单的高度,宽度和(x,y)
int rectWidth = preferWidth;
int rectHeight = preferHeight * LABELS.length;
int x = (getWidth()-rectWidth)/2;
int y = (getHeight()-rectHeight)/2;
//画矩形
g.drawRect(x,y,rectWidth,rectHeight);
for(int i = 1;i<LABELS.length;i++){
g.drawLine(x,y+preferHeight*i,x+rectWidth,y+preferHeight*i);
}
//画菜单选项,并根据selected的值判断焦点
for(int j = 0;j<LABELS.length;j++){
if(selected == j){
g.setColor(0x6699cc);
g.fillRect(x+1,y+j*preferHeight+1,rectWidth-1,preferHeight-1);
g.setColor(color);
}
g.drawString(LABELS[j],x+8,y+j*preferHeight+4,Graphics.LEFT|Graphics.TOP);
}
}请高手帮忙看看上面的代码,编译时说找不到符号 符号: 方法 getWidth()
位置: 类 MenuCanvas
g.fillRect(0,0,getWidth(),getHeight());
怎么会这样啊???
解决方案 »
- 这个生产者消费者程序为什么一运行就死循环
- Singleton 是线程安全的吗?
- 求救,JNative调用dll函数如何取得内存里的数据
- Reader类、Writer类与BufferedReader类、BufferedWriter类概念理解问题
- 如何积累项目经验?
- 如何让tooltip分行?
- JTree添加节点
- Exception in thread "main" java.lang.NoClassDefFoundError: maths (wrong name: cm/mxq/test/maths)
- 请教一个FileInputStream的问题
- JBuilder6.0在Linux下安装的问题?
- 小弟现在没有积分,请高手帮帮忙,线程的问题,小弟谢谢各位了
- 为什么会出现异常?
getSize().width();