Struggling in creating chessboard!!
Hey,I wanna create chessboard(only) without swings as i am a new programmer.Plz see this and say wats wrong with this code and necessary corrections
import java.awt.*;
import java.applet.*;
public class board2 extends Applet
{
int i=0,j=0,a=0;
public void init()
{
for(i=150;i<550;i+=50)//coordinates
{
for(j=50;j<=450;j+=50)//coordinates
{
a++;
repaint();
}
}
}
public void paint(Graphics g)
{
if((a%2)==0)
{
g.setColor(Color.lightGray);
g.fillRect(i,j,50,50);
g.drawRect(i,j,50,50);
}
if((a%2)==1)
{
g.setColor(Color.black);
g.fillRect(i,j,50,50);
g.drawRect(i,j,50,50);
}
}
}