I realize this code could be sketchy... But you could modify it to work for you. I have it currently working and checking the top row to see if they are all the same...
Code:
static int[][] MoveHistory = new int[3][3];
static class MoveHandler implements ActionListener //######
{
public void actionPerformed(ActionEvent event)
{
String whichButton;
whichButton = event.getActionCommand();
if (whichButton.equals("1"))
{ one.setText(player);
if (player.equals ("x")) MoveHistory[0][0] = 1;
else MoveHistory[0][0] = 2;
}
this.check();
if (whichButton.equals("2"))
{ two.setText(player);
if (player.equals ("x")) MoveHistory[0][1] = 1;
else MoveHistory[0][1] = 2;
}
this.check();
if (whichButton.equals("3"))
{ three.setText(player);
if (player.equals ("x")) MoveHistory[0][2] = 1;
else MoveHistory[0][2] = 2;
}
this.check();
if (whichButton.equals("4"))
{ four.setText(player);
if (player.equals ("x")) MoveHistory[1][0] = 1;
else MoveHistory[1][0] = 2;
}
this.check();
if (whichButton.equals("5"))
{ five.setText(player);
if (player.equals ("x")) MoveHistory[1][1] = 1;
else MoveHistory[1][1] = 2;
}
this.check();
if (whichButton.equals("6"))
{ six.setText(player);
if (player.equals ("x")) MoveHistory[1][2] = 1;
else MoveHistory[1][2] = 2;
}
this.check();
if (whichButton.equals("7"))
{ seven.setText(player);
if (player.equals ("x")) MoveHistory[2][0] = 1;
else MoveHistory[2][0] = 2;
}
this.check();
if (whichButton.equals("8"))
{ eight.setText(player);
if (player.equals ("x")) MoveHistory[2][1] = 1;
else MoveHistory[2][1] = 2;
}
this.check();
if (whichButton.equals("9"))
{ nine.setText(player);
if (player.equals ("x")) MoveHistory[2][2] = 1;
else MoveHistory[2][2] = 2;
}
this.check();
nine.setText(player);
if (whichButton.equals("x"))
{ JOptionPane.showMessageDialog( null, "click again"); // ****
}
if (whichButton.equals("o"))
{ JOptionPane.showMessageDialog( null, "click again");
}
if (player == "o" )
player = "x";
else player = "o";
int x=0;
for (int a=0;a<3;a++)
System.out.print(MoveHistory[a][x]);
System.out.println();
x++;
}
public void check(){
for(int i=0; i<3; i++){
if(MoveHistory[i][0]==MoveHistory[i][1] && MoveHistory[i][1]==MoveHistory[i][2]){
if(MoveHistory[i][0] == 1){
JOptionPane.showMessageDialog(null, "X Wins");
break;
}
if(MoveHistory[i][0] == 2){
JOptionPane.showMessageDialog(null, "O Wins");
break;
}
}
}
}
}