In my program, each user has a JComboBox. However, the number of users varies depending on how many users are specified at the start of the game.
As a result I decided to make an array of JComboBoxes:
private JComboBox characterBox;
Then, later I specify the size of the JComboBox:
I have no problem creating the JComboBoxes or adding them to the JPanel.
The problem occurs when I try to make actionlisteners. The following code is in a for loop that runs the number of users in the game.
public void actionPerformed( ActionEvent event )
String picNum = (String)characterBox
The problem is that the compiler tells me x must be final. However I can't have it final because I am looping the creating of the Listeners. I know the actionlistener code works but I can't figure out how to create all of the listeners in a for loop. Any thoughts? Thanks.