Hey guys,
I trying to make a tic tac toe game without buttons. It checks if the user clicked on any of the x, y postions in any of the squared. Now actually making the game, how would I differentiate each single square?

Heres the code

Code:
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.Line2D;
import javax.swing.*;

public class TicTacToe extends JPanel implements MouseListener, MouseMotionListener {


	private TTTSquare[] squares;
	public boolean playerOneTurn = true;
	public int xSpot, oSpot;
	
	
	public static void main(String[] args) {

		new TicTacToe();
	}

	public TicTacToe() {

		squares = new TTTSquare[9];
		int x = 50;
		int y = 110;
		int counter = 0;
		
		for (int i = 0; i < squares.length; i++)
		{
			counter++;
			squares[i] = new TTTSquare(x, y);
			x += 175;
			
			if (counter % 3 == 0)
			{
				y += 175;
				x = 50;
			}
		}
		
		setLayout(null);
		setBackground(Color.BLACK);
		addMouseListener(this);
		addMouseMotionListener(this);
		setFocusable(true);

		JFrame frame = new JFrame();
		frame.setContentPane(this);

		frame.setSize(550,700);
		frame.setResizable(false);
		frame.setTitle("Tic Tac Toe");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
		frame.setLocationRelativeTo(null);
	}
	public void drawTitle(Graphics2D g2) {

		Font f = new Font("Stencil", Font.BOLD, 50);
		g2.setColor(Color.orange);
		g2.setFont(f);
		FontMetrics fm = getFontMetrics(f);
		int strW = fm.stringWidth("Tic Tac Toe");
		g2.drawString("Tic Tac Toe", this.getWidth() / 2 - strW / 2, 50);
		
	}
	
	public void drawPlayerTurn(Graphics2D g2) {
		
		Font f = new Font("Arial Black", Font.BOLD, 20);
		g2.setColor(Color.white);
		g2.setFont(f);
		FontMetrics fm = getFontMetrics(f);
		int strW = fm.stringWidth("Player 1");
		if(playerOneTurn) {
			g2.drawString("Player 1", this.getWidth() / 2 - strW / 2, this.getHeight() - 20);
		}
		else 
		{
			g2.drawString("Player 2", this.getWidth() / 2 - strW / 2, this.getHeight() - 20);
		}
	}
	
	public void drawGrid(Graphics2D g2) {
		
		g2.draw(new Line2D.Double(this.getWidth() / 3, 75, this.getWidth() / 3, this.getHeight() - 75));
		g2.draw(new Line2D.Double(this.getWidth() * 3/4 - 40, 75, this.getWidth() * 3/4 - 40, this.getHeight() - 75));
		g2.draw(new Line2D.Double(25, 75 + (550 / 3), this.getWidth() - 25, 75 + (550 / 3)));
		g2.draw(new Line2D.Double(25, this.getHeight() * 3/4 - 70, this.getWidth() - 25, this.getHeight() * 3/4  - 70));
	}
	public void paintComponent (Graphics g) {

		super.paintComponent(g);
		Graphics2D g2 = (Graphics2D) g;
		g2.setStroke(new BasicStroke(5));
		g2.setColor(Color.RED);
		drawGrid(g2);
		drawTitle(g2);
		drawPlayerTurn(g2);
		
		for (int i = 0; i < squares.length; i++)
		{
			squares[i].draw(g2);
		}
		
//		ImageIcon o = new ImageIcon("o.png");
//		g2.drawImage(o.getImage(), 50, 110, this);
//		
//		ImageIcon x = new ImageIcon("x.png");
//		g2.drawImage(x.getImage(), 300, 300, this);
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		
		
		for (int i = 0; i < squares.length; i++)
		{
			if (e.getX() >= squares[i].getX() && e.getX() <= squares[i].getX() + squares[i].getWidth())
			{
				if (e.getY() >= squares[i].getY() && e.getY() <= squares[i].getY() + squares[i].getHeight())
				{
					if(playerOneTurn) {
						squares[i].setImage("x");
						playerOneTurn = false;
					}
					else {
						squares[i].setImage("o");
						playerOneTurn = true;
					}
					
					
				}
			}
		}
		
		repaint();
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseDragged(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseMoved(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}


	
	
	
}
Code:
import java.awt.*;
import java.awt.geom.Rectangle2D;

import javax.swing.*;

public class TTTSquare {

	private int xPos, yPos, width, height;
	private ImageIcon imgX, imgO, imgSquare;
	private boolean drawImage;
	
	public TTTSquare(int x, int y) {
		
		drawImage = false;
		imgX = new ImageIcon("X.png");
		imgO = new ImageIcon("O.png");
		imgSquare = null;
		width = imgX.getIconWidth();
		height = imgX.getIconHeight();
		xPos = x;
		yPos = y;
	}
	
	public Rectangle getBounds() {
		
		return new Rectangle(xPos, yPos, width, height);
	}
	
	public int getX() {
		
		return xPos;
	}
	
	public int getY() {
		
		return yPos;
	}
	
	public int getWidth() {
		
		return width;
	}
	
	public int getHeight() {
		
		return height;
	}
	
	public void setImage(String letter) {
		
		if (letter.equalsIgnoreCase("x"))
		{
			imgSquare = imgX;
			drawImage = true;
		}
		else
		{
			drawImage = true;
			imgSquare = imgO;
		}
	}
	
	public void draw(Graphics2D g2) {
		
		if (drawImage == false)
		{
			g2.setColor(Color.BLACK);
			g2.fill(new Rectangle2D.Double(xPos, yPos, width, height));
		}
		else
		{
			g2.drawImage(imgSquare.getImage(), xPos, yPos, null);
		}
	}
}