I want to add an EventHandler for multiple JButtons in Java. I use a JButton array JButton[] buttons = new JButton[120]
. I used this solution
for (int i=0; i<btns.length; i++){
buttons[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
}
but i think the above code is bad.