I am using a for loop to create a grid of 60 JButtons. What I want to do is have the name of the actionListener increment each time the loops runs:
for (int y = 0; y < game.getHeight(); y++) {
for (int x = 0; x < game.getWidth(); x++) {
JButton square = new JButton();
square.setFont(new Font("Verdana", Font.PLAIN, 20));
ActionListener bh = new button_handler();
square.addActionListener(bh);
grid.add(square);
}
So I would like the name to increment (bh_1, bh_2, bh_3, etc).
Thanks!