Hey guys im back again with a problem, i am trying to add circles to my board but i cannot do it, i am getting one error.

cannot find symbol
symbol : variable Col
location: class SimpleDrafts
g.fillOval(4 + Col*20, 4 + Row*20, 15, 15);?

Anyone know the prob??

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.ArrayList;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JOptionPane;


import javax.swing.*;

public class SimpleDrafts  implements MouseListener // Initial Board Class
{

    protected JPanel[][] squares;
    protected JFrame boardFrame; // Basic frame for pieces to be added onto
    protected Container container;
    private JLabel message;
    private static Graphics circle;
    public void paint (Graphics g) { }




    public SimpleDrafts ()
    {

    	boardFrame = new JFrame("MyDraughts");
    	//boardFrame.setBounds(20,20,164,164);
        container = boardFrame.getContentPane();
        boardFrame.setJMenuBar (MyMenu());
        container.setLayout(new GridLayout(8,8));
        boardFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
       // create_squares(Graphics g);
        boardFrame.setSize(400,450);
        boardFrame.setVisible(true);
    }


    private void create_squares(Graphics g)// Creates the Squares for the pieces
    {

		g.setColor(Color.black);
		//g.drawRect(0,0,getSize().width-1,getSize().height-1);
       // g.drawRect(1,1,getSize().width-3,getSize().height-3);

		int EMPTY = 0;
		int RED = 1;
	    int RED_KING = 2;
	    int BLACK = 3;
		int BLACK_KING = 4;

        squares = new JPanel[8][8];
        for(int Row=0;Row<8;Row++)
        {
			g.setColor(Color.RED);
            g.fillOval(4 + Col*20, 4 + Row*20, 15, 15);
            for(int Col=0;Col<8;Col++)
            {
				g.setColor(Color.BLACK);
                g.fillOval(4 + Col*20, 4 + Row*20, 15, 15);

            	JPanel p = new JPanel();
                p.setBackground(setColor(Row,Col));
                p.addMouseListener(this);
                squares[Row][Col]=p;
                container.add(p);
            }
        }
    }


    private Color setColor(int x, int y) //Puts the color of the board either black or white
    {
        if((x+y)%2 == 0)

            return Color.WHITE;

        else
            return Color.BLACK;
    }



    private JMenuBar MyMenu()

	      {

	       // Creates a menu Bar

	      JMenuBar MyMenuBar = new JMenuBar();
	      JMenu fileMenu = new JMenu("Options");
	      //Declare Menu Items and add them to the first menu
	     JMenuItem newMenuItem = new JMenuItem ("New Game");
	     fileMenu.add(newMenuItem);
	     JMenuItem resignMenuItem = new JMenuItem ("Resign");
	     fileMenu.add(resignMenuItem);
	     JMenuItem ExitMenuItem = new JMenuItem ("Exit");
	     fileMenu.add(ExitMenuItem);
	     ExitMenuItem.addActionListener(new ActionListener(){ // Will close the game when the user picks exit
			 public void  actionPerformed(ActionEvent e){
				 System.exit(0);
			 }
		 });

	     fileMenu.addSeparator();

	      MyMenuBar.add(fileMenu); // Adds menubar

	      return MyMenuBar;


      }

    public static void main (String args[])
    {
		for(int i=0; i<8; i++)
        {
    	//squares[1][i].addDraftsPiece(new DraftsPiece);  	// Another way i tried to add the pieces
		}
    	SimpleDrafts b = new SimpleDrafts();
    }





	public void mouseClicked(MouseEvent me) // This was my method to add the pieces,
											//however i could only manage tp draw them on using the mouse clicked event
	{
		boolean isFound = false;
		int i = 0;
		int j = 0;
		for(i=0; !isFound && i<8;i++)		//It traveled through my array and allowed me to draw and the squares accordingly.
		{
			for(j=0;j<8;j++)
			{
				if(me.getSource().equals(squares[i][j]))
				{
					isFound = true;
					break;
				}
			}
		}

		isFound = false;
		JPanel temp = squares[i-1][j];
		setCircle(temp);
	}

	public void setCircle(JPanel temp)  // Here is where the circle is supposed to de attached
	{
		circle = temp.getGraphics(); // Circle was drawn
		circle.setColor(Color.RED);
    	circle.fillOval(15, 15, 20, 20);

		/*
		if(temp.isCircleThere())
		{
			temp.circleRemoved();
			temp.getJLabel().setIcon(null);				////Caused errors
		}
		else
		{
			temp.circleAdded();
			temp.getJLabel().setIcon(icon);
		}*/
	}




	public void mouseEntered(MouseEvent arg0) {

	}





	public void mouseExited(MouseEvent arg0) {


	}





	public void mousePressed(MouseEvent arg0){
	}





	public void mouseReleased(MouseEvent arg0) {

	}
}

Scrap that! Got it!

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.