I have something like the code below:
for(int i=0;i<10;i++){
button=new JButton(buttons[i]);
button.addActionListener(new ActionListen
The variable i is in fact in the scope of the ActionListener, but since you're trying to use a local variable in an inner class, the variable must be final. So, you could use a final variable for this:
for(int i=0;i<10;i++){
final int index = i;
button=new JButton(buttons[i]);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
setPage(index);
}
});
menu.add(button);
}