简体   繁体   English

使用Canvas J2ME为背景填充2种颜色

[英]Fill 2 color for background with Canvas J2ME

Im new in J2ME, and i very interested in canvas because it can do a lot of work but i have trouble is define coordinate X and Y 我是J2ME的新手,我对画布非常感兴趣,因为它可以完成很多工作,但是我很难定义坐标X和Y

I try to fill my screen with 2 color Green and Gray but it miss a part above screen: 我尝试用绿色和灰色2种颜色填充屏幕,但屏幕上方缺少一部分:

I need you help 我需要你的帮助

Thank you!! 谢谢!!

second occurrence of i * size in fillRect in rev 3 of your question feels slippery 问题的修订版3fillRecti * size第二次出现感觉很滑

    int size = 50;
    for(int i = 0; i < itemsPerLines.length; i++){
         int x = 0 + 1, y = i * size,
                width = getWidth() - 2, height = size /* not i*size */;
         if(i % 2 == 0){
             g.setColor(0x00ff00); // green - not 0x0ff000
         }else{
             g.setColor(0x414141);
         }
         g.fillRect(x, y, width, height);
         g.setColor(0xff00ff); // red + blue? wonder how it looks
         int x1 = i * size, y1 = y;
         g.drawLine(x, y, x1, y1);


    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM