Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void actionPerformed(ActionEvent e) {
- if (isGameOver) {
- return;
- }
- JButton currentcell = (JButton) e.getSource();//e in typecasted to jbutton type
- if (currentcell.getText().length() > 0) {
- return;
- }
- currentcell.setText(currentPlayer);
- if (hasWon(currentPlayer)) {
- isGameOver = true;
- JOptionPane.showMessageDialog(this, currentPlayer + " has won.");
- return;
- }
- currentPlayer = currentPlayer.equals(PLAYER1)
- ? PLAYER2
- : PLAYER1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement