Dror is correct assuming that your array is globally available.
I have run into a similar question as this topic numerous times dealing with either arrays which are not globally accessable or the JButton (or whatever) were not saved at all as the screen was dynamically created. In this case I would use JButton.setActionCommand(
String) where the String I would give it would be which button it is... ie: Button 1, Button 2, etc..