I have a JButton array
button[100]
and use is in more than one method, one creating the 100 buttons and one the action listener
i’ve used
String abc=button[i].setActionCommand(String.format("Button %d", i));
to find what button was pressed but variable button can’t be identified.
You need to give your variable more than local method scope. If you define it as a instance variable of the class, it will be accessible anywhere inside that class.