Even though this is an instance of the anonymous type, you should still be able to call methodX("str") just don't prefix it with this If you want to be explicit, I think there is some syntax which lets you do it - you can write ParentClass.this. MethodX("str") but personally I wouldn't bother being explicit unless you really have to (e.g. To disambiguate the call from a method in MouseListener ).
Even though this is an instance of the anonymous type, you should still be able to call methodX("str") - just don't prefix it with this. If you want to be explicit, I think there is some syntax which lets you do it - you can write ParentClass.this. MethodX("str"); but personally I wouldn't bother being explicit unless you really have to (e.g.To disambiguate the call from a method in MouseListener).
You do not need to do anything but to remove this from the call. If you still want to use this you have to have the prefix ParentClass. E.g.ParentClass.this.
MethodX(...)... But that's just ugly and should be used when needed (naming collisions etc).
I don't use this before any of my other method calls within a class. – dacwe Nov 21 '10 at 17:05 me too, and this is why methodX referring to the container class sometimes confuses me. Just personal taste, you're right – khachik Nov 21 '10 at 17:09.
As other have stated, simply remove this. And you should be able to call method in the outer class. In those rare cases when the outer class and the nested class have methodS with THE same name and parameter list you call it with OuterClass.this.
SomeMehtod(...);. For cleaner code when writing anonymous inner classes, I advice you to use adapters. For many of Swings interfaces, there's abstract adapters implementing them and you only override the methods of interest.In this case it would be MouseAdapter: class ParentClass { void ParentMethod() { swing_obj.
AddMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { someMethodX(); } }); } void methodX(String x) { //... } }.
And you should be able to call method in the outer class. In those rare cases when the outer class and the nested class have methodS with THE same name and parameter list you call it with OuterClass.this. For cleaner code when writing anonymous inner classes, I advice you to use adapters.
For many of Swings interfaces, there's abstract adapters implementing them and you only override the methods of interest.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.