import javax.microedition.lcdui.*; public class MyCanvas extends Canvas { public MyCanvas() { } int r = 0; int g = 0; int b = 0; public void paint(Graphics g) { g.setColor(50,65,100); g.fillRect(0,0,getWidth(),40); g.setColor(r,g,b); g.drawString("r-"+r+"; g-"+g+"; b"+b, 5, 45,Graphics.LEFT|Graphics.VCENTER); } protected void keyPressed(int keyCode) { if (r<0) r=0; if (g<0) g=0; if (b<0) b=0; if (r>255) r=255; if (g>255) g=255; if (b>255) b=255; switch (keyCode) { case KEY_NUM1: r--; break; case KEY_NUM3: r++; break; case KEY_NUM4: g--; break; case KEY_NUM6: g++; break; case KEY_NUM7: b--; break; case KEY_NUM9: b++; break; } repaint(); } }