Hi, i have a problem with my program not compiling. It says "(" Expected on line 31, when there is in fact a bracket there.
Thanks in advance.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class TicTacToe extends JFrame implements ActionListener {
JButton[][] x = new JButton[3][3];
int[][] a = new int[3][3];
int turn;
public static void main(String[] args) {
TicTacToe f = new TicTacToe();
f.setSize(500,500); f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public TicTacToe(){
setLayout(new GridLayout(3,3));
for (int r = 0; r < 3; r++){
for (int c = 0; c < 3; c++){
x[r][c] = new JButton();
add(x[r][c]);
x[r][c].addActionListener(this);
}
}
}
public void actionPerformed(ActionEvent e){
for (int r = 0; r < 10; r++){
for(int c = 0; c < 10; c++){
if (e.getSource()== x[r][c]){
if turn == 0{
x[r][c].setText("O");
turn = 1;
}
else {
x[r][c].setText("X");
turn = 0;
}
}
}
}
}
}