This content has been marked as final. Show 4 replies
What doesn't work, does it make your toaster explode? Post the exact errormessages/stack traces you get.
you have to be more precise: it doesn't compile. When you so "it don't work" (and it is "it DOESN'T work") then people will assume you are talking about running the application. You will also want to post the actual error you get when asking for help, otherwise you are making people guess.
The error you get is this:
local variable label is accessed from within inner class; needs to be declared finalYou're a student, your whole world right now is learning new stuff. What is stopping you from reading into inner classes and this 'final' thing the error is referring to?
Anyway, I would try actually making the label a member of your class, like that myPanel.
Thank you. I've changed
JLabel label = new JLabel("0");
and it's working now. Yes the problem was that source code couldn't be compiled.
final JLabel label = new JLabel("0");
I dont know why the final word is doing the thing here. And I dont know how to make the label a member of my class. Yes I'll read about the inner classes, thanks.
I dont know why the final word is doing the thing here.It's marking that the value of variable label cannot change. This value is a reference to an object, and if it could change then when the code in the inner class is executed the reference would be ambiguous.
And I dont know how to make the label a member of my class. Yes I'll read about the inner classes, thanks.Hint: myPanel is a member of your class :)