I posted this question earlier in a much larger form, and hope to post it again in a way that allows the community to help me better, by dumping less information on you all.
Fundamentally, I have this code, explained below:
for(JMenuItem x : chem3_x_y){
x.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent k) {
new SwingImplementation(1, tt+1);
}
});
gEleven[6].add(x);
tt++;
}
tt=0;
First, I cycle through all of the JMenuItem-s in the array chem3_x_y
Then, I add an ActionListener to 'x', or each item of the array, which creates a new SwingImplementation with the arguments of 1, and the variable 'tt'
Following this, the JMenu gEleven receives the JMenuItem in question, I then increase tt by 1.
The purpose of the above code is to automate the process of adding JMenuItems to gEleven, and ActionListeners to each Menu Item.
The problem, the argument passed for the variable 'tt' is always the same, 1, as if the action listener with the argument for 'tt' of 1 is applied to every JMenuItem - why could that be, and how can I use the ever-increasing tt to create one ActionListener per JMenuItem, with the argument of (1, tt) without tt always being 1