import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
//简单的canvas by sword2008@程序之巢
public class test2 extends MIDlet{
private Display display;
public test2(){
display=Display.getDisplay(this);
}
public void startApp(){
display.setCurrent(new test());}
public void pauseApp(){ }
public void destroyApp(boolean unkowmn){ }
class test extends Canvas
{
public void paint(Graphics g){
g.setColor(255,255,0);
g.fillRect(0,0,getWidth(),getHeight());
int c=g.getColor();
int d=g.getDisplayColor(g.getColor());
System.out.println("当前画面的颜色为:"+Integer.toHexString(c));
System.out.println("当前画面的R值为:"+g.getRedComponent());
System.out.println("当前画面的G值为:"+g.getGreenComponent());
System.out.println("当前画面的B值为:"+g.getBlueComponent());
System.out.println("当前画面的显示颜色为:"+Integer.toHexString(d));
System.out.println("当前画面的灰度为:"+g.getGrayScale());
}
}
}
评论