|
As you've said, a loop to apply an action listener to each of the buttons.
An alternative could be to use a JList and render it to look and act like button's instead. This would only require one listener since each of the items is a part of the JList collection and not a separate component like an array of JButton is.
|