I am having a massive issue in the for loop below, I am trying to create action listeners for a series of JButtons, and each JButton has to assign a different value to 'Column' and 'Row', but, for all the buttons 'Column' and 'Row' are only becoming the highest possible value of the for loop, as in if in the for loop m went up to 7, 'Column' would equal 7 for all the buttons, it does not incriment. In other words, I want the first button 'but[0][0]' to make 'Column' equal to 0, but I also want 'but[1][0]' make 'Column' equal to 1, and so on. Any help would be greatly appreciated.
The purpose of the buttons is to change the value of 'Column' and 'Row' which are declared elsewhere in the program, so each button needs to make 'Column' and 'Row' equal something different.
for (m = 0; m < width; m++){
for (n = 0; n < width; n++){
but[m][n].addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e){
Column = m;
Row = n;
enablenumbers();
disablecolumns();
disablerows();
choose.setText("Now Choose The Nummber You Want To Put In This Square");
}
}
);
}
}