绘制一个网格的程序
import java.applet.Applet;
import java.awt.*;
public class Exam4_7 extends Applet
{
public void paint(Graphics g)
{
int x0=10,y0=10,dx=15,dy=20,N=15,M=15;
int x1,x2,y1,y2;
y1=y0;
y2=y0+M*dy;
for(int i=0;i<=N;i++)
{
X1=x0+i*dx;
g.drawLine(x1,y1,x2,y2);
}
g.setColor(Color.red);
x1=x0;
x2=x0+N*dx;
for(int j=0;j<=M;j++)
{
y1=y0+j*dy;
g.drawLine(x1,y1,x2,y1);
}
}
}