I want the reference variable for a JButton (say... b1) to automatically change with each iteration of a for loop. So:
[CODE] for(int i=0;i<12;i++) { JButton b1 = mainButtonList.get(b1); //Code to edit each button specifically... (if statements) mainButtonList.set(i,b1); b1 = null; [/CODE]
As you can see, there is only one reference variable right now so I'm not sure how I can really have any action listener figure out which button was pressed.
getSource will return the reference variable. If they all are the same, how can you differentiate?
What I am looking for is to change the reference used with each iteration. So maybe add some sort of b(i) statement so that the number next to be changes each time. But, I'm not sure if that would work since Java takes b(i) as the full reference variable if I'm not mistaken.
Is this possible? If not, do you have any other suggestion?
Thanks for your time!