java - How can I access enclosing class instance variables from inside the anonymous class? -
how access instance variables
inside anonymous class's method ?
class tester extends jframe { private jbutton button; private jlabel label; //..some more public tester() { function(); // call function } public void function() { runnable r = new runnable() { @override public void run() { // how access button , label here ? } }; new thread(r).start(); } }
how access
instance variables
inside anonymous class's method ?
you access them if need be:
class tester extends jframe { private jbutton button; private jlabel label; //..some more public tester() { function(); // call function } public void function() { runnable r = new runnable() { @override public void run() { system.out.println("button's text is: " + button.gettext()); } }; new thread(r).start(); } }
more important: why isn't working you?
Comments
Post a Comment