I думаю, вы хотите этого - просто создаете переменную final
в цикле, принимая ее значение из i
, чтобы вы могли ссылаться на нее в своем анонимном внутреннем классе:
ArrayList<Kaart> thand = uno.gethSpeler().getHand();
for(int i=0; i < thand.size(); i++) {
final int copy = i;
btnArr[i].setIcon(thand.get(i).getImg());
btnArr[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
iKaart = copy;
}
});
}