Hi again
I've got a lot of mostly identical JButtons (60), which I put into an array, to save time.
Code:
JButton[] arsenalSel = new JButton[60];
which I add with a For loop
Code:
GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.WEST; //Align to the left?
for(int i =0; i < 60; i++)
{
String tempwep = "";
tempwep = "" + wMaster.allWeapons[i].name;
arsenalSel[i] = new JButton(tempwep+"");
c.gridx = 1; c.gridy = i; parsn.add(arsenalSel[i], c);
}
This gives me an array of 60 buttons which get their contents from another object called wMaster, which are added to a JPanel.
My Problem: I need an actionlistener for each button. I don't want to have to do 60 of them.
What I need is some sort of actionlistener which listens to the whole array at once. Failing that, I need a way to do use a loop to make actionlisteners.
Any ideas?