How do I access
instance variables
from inside the anonymous class's method ?
You simply 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 this working for you?