|
@ -1,4 +1,5 @@ |
|
|
package TicTacToe; |
|
|
package TicTacToe; |
|
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
import java.awt.Color; |
|
|
import java.awt.event.ActionEvent; |
|
|
import java.awt.event.ActionEvent; |
|
|
import java.awt.event.ActionListener; |
|
|
import java.awt.event.ActionListener; |
|
@ -12,6 +13,7 @@ public class cell extends JButton { |
|
|
|
|
|
|
|
|
public cell(TicTacToeGame _ttt) { |
|
|
public cell(TicTacToeGame _ttt) { |
|
|
ttt = _ttt; |
|
|
ttt = _ttt; |
|
|
|
|
|
setBackground(new Color(255,255,255)); |
|
|
|
|
|
|
|
|
addActionListener(new ActionListener() { |
|
|
addActionListener(new ActionListener() { |
|
|
@Override |
|
|
@Override |
|
@ -28,17 +30,20 @@ public class cell extends JButton { |
|
|
setEnabled(false); |
|
|
setEnabled(false); |
|
|
|
|
|
|
|
|
switch (playerID) { |
|
|
switch (playerID) { |
|
|
case 1: setBackground(new Color(255,0,0)); |
|
|
|
|
|
break; |
|
|
|
|
|
case 2: setBackground(new Color(0,0,255)); |
|
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
setBackground(new Color(255, 0, 0)); |
|
|
break; |
|
|
break; |
|
|
default: ; |
|
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
setBackground(new Color(0, 0, 255)); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void reset() { |
|
|
|
|
|
playerID = 0; |
|
|
|
|
|
setEnabled(true); |
|
|
|
|
|
setBackground(new Color(255,255,255)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |