Hello.
I am creating a minesweeper game. I wanted to make it so that when I click on any of minesweeper fields (I used jButtons for them), the button would change to the right picture of number, mine, or empty field. Since there are many buttons, I added a method that does all this, you just need to insert array pointers for each button. The problem arose when I found out that setting the button to a picture needs a specific variable. And since the variable will be different with each new click, I can't use a method. One option is to add all these +50 lines to EACH button, but that would make my code unreadable and waste a lot of time. Is there any way to change variables?

The jButton1 is there just for an example.

Java Code:
else if(tab[x][y] == 1){
            jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/"+c+".png")));
        }