In class my teacher ran a program similar to this one. When I attempt to run this from home I get a message saying "No main classes found". I know there should be a main in the program but he ran a similar program without it. Just trying to get some insight on how to run this. This is basically just a program that makes a checkerboard pattern then it draws the checkers on top.

package checkers1;
import java.awt.*;
public  class Checkers1 {
static
    int columns = 8;
    int rows = 8;
    int sizeofsquare = 50;
   

    void maketheboard(Graphics g) {
        for(int row = 0; row<rows; row++)
            for(int column = 0; column<columns; column++){
                if((row+column)% 2==0)
                {
                    g.setColor(Color.LIGHT_GRAY);
                }
        else
            g.setColor(Color.GRAY);
            g.fillRect(20+column*sizeofsquare,20+row*sizeofsquare,
                    sizeofsquare,sizeofsquare);
    }

}

   private void checkerTime(Graphics g) {
         for(int row = 0; row<rows; row++)
              for(int column = 0; column<columns; column++)
                  if((row+column)% 2==1)
                      if (row <3)
                      {
                          g.setColor(Color.white);
                          g.fillOval(20+column*sizeofsquare, 20+row*sizeofsquare,
                                  sizeofsquare-2, sizeofsquare-2);

         if (row >= rows -3)
         {
             g.setColor(Color.black);
             g.fillOval(20+column*sizeofsquare,20+row*sizeofsquare,
                     sizeofsquare-2, sizeofsquare-2);
                          }
                      }
    
    }
  public void draw(Graphics g)
    {
        maketheboard(g);
        checkerTime(g);
}
}

Recommended Answers

All 4 Replies

Start this as an applet

package checkers1;
import java.awt.Graphics;
import javax.swing.JApplet;
public class Check extends JApplet {

    private Checkers1 ck;

    @Override
    public void init() {
        super.init();
        ck = new Checkers1();
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        ck.draw(g);
    }
}

Thanks quuba. I got it working. :)

nice, mark solved

sure thing....but how do I do that? lol :)

NVM I FOUND IT lol

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.