Without attempting to change the structure of your program so far, here is a "naive" approach.
Instead of using an Anonymous Inner Class, you could create another class:
public class MyListener implements ActionListener {
private int x;
private int y;
public MyListener(int x, int y){
this.x = x;
this.y = y;
}
@Override
public void actionPerformed(ActionEvent e) {
//do something with this.x
//do something with this.y
}
}
and then you can adapt this to your code:
jBTN_field[y][x].addActionListener(new MyListener(x, y));
Now, for accessing the coordinate of a button, it will be as simple as:
button[y][x].
NOTE
Your code is not logically wrong. I'm just showing you an alternative, that could simplify things for you, so you can solve your problem more methodically. The example I have showed, is appropriate if you want to have the same actionPerformed()
functionality for all buttons. Otherwise, an anonymous inner class is more appropriate.
Alternatively, should you wish to keep your code as is, you can do:
jBTN_field[y][x].addActionListener(new ActionListener() {
int x = "value_for_x", y = "value_for_y";
@Override
public void actionPerformed(ActionEvent pE) {
//do something with x
//do something with y
}
}