I am trying to develop a GUI for a Chess / Checkers game. When attempting to add ActionListeners to the buttons, Netbeans seems to give me a whole bunch of errors with suggestions that doesn't seem to solve the problem.
Here is the part of the code in question:
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
squares[i][j].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (!pressed) {
pressed = true;
fromR = i;
}
throw new UnsupportedOperationException("Not supported yet.");
}
});
}
}
squares[][] is the array all the buttons are stored in; the error occurs on the line fromR = i;
Is there a better way to add ActionListeners into buttons stored in arrays altogether?