|
|
@ -134,6 +134,19 @@ public class GameLogic implements ActionListener { |
|
|
|
return this.fields[column][row]; |
|
|
|
} |
|
|
|
|
|
|
|
private void updateGUI() { |
|
|
|
if (this.checkEndOfGame()) { |
|
|
|
for (int i = 0; i < this.fields.length; i++) { |
|
|
|
for (int j = 0; j < this.fields.length; j++) { |
|
|
|
this.fields[i][j].setEnabled(false); |
|
|
|
} |
|
|
|
} |
|
|
|
JOptionPane.showMessageDialog(contentPanel, "Spieler " + this.currentPlayer + " hat gewonnen."); |
|
|
|
System.exit(0); |
|
|
|
} |
|
|
|
this.switchPlayer(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
for (int i = 0; i < this.fields.length; i++) { |
|
|
@ -141,21 +154,11 @@ public class GameLogic implements ActionListener { |
|
|
|
if (e.getSource() == this.fields[i][j]) { |
|
|
|
this.setField(i, j, currentPlayer); |
|
|
|
this.fields[i][j].setText("" + this.getCurrentPlayer()); |
|
|
|
|
|
|
|
if (this.checkEndOfGame()) { |
|
|
|
JOptionPane.showMessageDialog(contentPanel, "Spieler " + this.currentPlayer + " hat gewonnen."); |
|
|
|
for (int k = 0; k < this.fields.length; k++) { |
|
|
|
for (int l = 0; l < this.fields.length; l++) { |
|
|
|
this.fields[k][l].setEnabled(false); |
|
|
|
} |
|
|
|
} |
|
|
|
System.exit(0); |
|
|
|
} |
|
|
|
this.switchPlayer(); |
|
|
|
|
|
|
|
updateGUI(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |