JComboBox[] ChooseType = new JComboBox[a];
JRadioButton[] Primary = new JRadioButton[a];
ButtonGroup group = new ButtonGroup();
for (int b = 0; b < a; b++) {
ChooseType[b] = new JComboBox(Types);
Primary[b] = new JRadioButton();
group.add(Primary[b]);
Primary[b].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ChooseType[b].setSelectedIndex(8);//Error here
}
});
}
I already tried this:
final JComboBox[] ChooseType = new JComboBox[a];
I tried also to create a inner class and a method, so I dont have to deal directly with the JComboBox inside the actionPerformed. Can someone tell me how to fix it?