I think I’ve coded myself into a bit of a corner here. I am trying to do something to this effect using java swing.
On click of the button next, load a new line from a file (via line index number), then if the date from the line in the file has not yet arrived, grey out the next button. My issue is that when I have the following code:
Scanner input = new Scanner(System.in);
System.out.println("Enter week number");
int j = input.nextInt();
String[] strArray = new String[4];
xmlLoader(j, strArray);
JButton nextButton = new JButton("Next");
nextButton.setBounds(750, 250, 80, 30);
nextButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
j++;
doNext(j, nextButton);
}
});
I cannot pass the j because it’s not final, and I can’t change anything on the button if it’s final, helpppp!
Specific error: local variable j is accessed from within inner class; needs to be declared final
You may define
jas a field in outer class.