From 4d2b57860607190bb2fe97eb7dfd9e2a160e7b77 Mon Sep 17 00:00:00 2001 From: fdai6040 Date: Tue, 7 Feb 2023 10:07:07 +0100 Subject: [PATCH] Tic Tac Toe creating method if player x wins --- src/main/java/src/TicTacToeGame.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/src/TicTacToeGame.java b/src/main/java/src/TicTacToeGame.java index 58ada26..4da2ea2 100644 --- a/src/main/java/src/TicTacToeGame.java +++ b/src/main/java/src/TicTacToeGame.java @@ -93,11 +93,23 @@ public class TicTacToeGame implements ActionListener { } } + //method if player X wins private void xWin(int i, int i1, int i2) { + bton[i].setBackground(Color.PINK); + bton[i1].setBackground(Color.PINK); + bton[i2].setBackground(Color.PINK); + + for (int j = 0; j < 9; j++) + { + bton[j].setEnabled(false); + } + textfield.setText("Player X wins"); } + + //Method for performing action after every turn @Override public void actionPerformed(ActionEvent e) {