Browse Source

4gewinnt: added actionListener to buttons

4gewinnt
Steffen Helmke 3 years ago
committed by Lorenz Hohmann
parent
commit
dc09cc88a9
  1. 29
      src/main/java/de/tims/viergewinnt/ai/Logic.java

29
src/main/java/de/tims/viergewinnt/ai/Logic.java

@ -2,6 +2,8 @@ package de.tims.viergewinnt.ai;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
@ -27,6 +29,7 @@ public class Logic {
for(int i = 0; i < buttons.length; i++) {
buttons[i] = new JButton(Integer.toString(i+1));
buttons[i].addActionListener(new ButtonListener());
buttonPanel.add(buttons[i]);
}
@ -39,6 +42,32 @@ public class Logic {
return contentPanel;
}
class ButtonListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == buttons[0]) {
}
if(e.getSource() == buttons[1]) {
}
if(e.getSource() == buttons[2]) {
}
if(e.getSource() == buttons[3]) {
}
if(e.getSource() == buttons[4]) {
}
if(e.getSource() == buttons[5]) {
}
}
}
public boolean testForWin(int[][] playfield, int player) {
int chain = 0;
for(int i = 0; i < playfield[0].length; i++) {

Loading…
Cancel
Save