java blog

java boy

常用链接

统计

最新评论

javaME 线与弧形

 

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;


public class GraphicsTest extends MIDlet{
  private Display display;

    public GraphicsTest() {
        display=Display.getDisplay(this);

    }
 
    protected void destroyApp(boolean unconditional)  {
     
       
    }

    protected void pauseApp() {
       
    }

    protected void startApp(){
     MyCanvas mc=new MyCanvas();
     display.setCurrent(mc);
    }


}
class MyCanvas extends Canvas {

    public void paint(Graphics g){
     int width=getWidth();
     int height=getHeight();
    
     g.setColor(0);
     g.fillRect(0, 0, width, height);
    
     int a=width/5;
     int b=height/5;
     g.setColor(0Xffff00);
     for(int i=1;i<=4;i++){
     g.drawLine(a,0 ,a,height);
     g.drawLine( 0,b,  width,b);
     a=a+width/5;
     b=b+height/5;
    
     } g.drawArc(0, 0, width, height, 0, 360);
    }

}

 

posted on 2009-12-01 20:01 javaz 阅读(165) 评论(0)  编辑  收藏 所属分类: javaME


只有注册用户登录后才能发表评论。


网站导航: