import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
//made by sword2008·程序之巢
//http://blog.programfan.com/blog.asp?author=qq14923349
//游戏第一课 画格子
public class Gofirst1 extends MIDlet
{
public Gofirst1(){
}
public void startApp(){
Display.getDisplay(this).setCurrent(new First1());
}
public void pauseApp(){}
public void destroyApp(boolean unkown){}
}
class First1 extends Canvas
{ private int color;
private int startX=getWidth()/4-40;//起点坐标和终点坐标非常重要,格子剩下的是分成等分
private int startY=getHeight()/4-40;
public void paint(Graphics g){
color=g.getColor();
g.setColor(255,255,255);
g.fillRect(0,0,getWidth(),getHeight());
g.setColor(255,0,0);
g.drawRect(startX,startY,200,200);
drawline(g);
}
private void drawline(Graphics g)//画格子
{ for(int i=1;i<11;i++){//横线 x坐标不边,y分别分成10等分,从上画下,
g.drawLine(startX,startY+200/10*i,startX+200,startY+200/10*i);
//竖线
g.drawLine(startX+200/10*i,startY,startX+200/10*i,startY+200);
}
}
}
评论