Take the following example. There's an object I want to use, call it a Doodad
. Doodad
elements have poorly implemented handling of browser events. Typical instantiation of a Doodad
would be Doodad someDoodad = new Doodad();
. Obviously this isn't suiting my needs because of the poor event handling. Is it appropriate for me to override the onBrowserEvent()
method, like so:
Doodad someDoodad = new Doodad() {
@Override
public void onBrowserEvent(Event event) {
switch (DOM.eventGetType(event)) {
case Event.ONDBLCLICK:
case Event.ONFOCUS:
case Event.ONCLICK:
if (!isEnabled()) {
return;
}
break;
}
super.onBrowserEvent(event);
}
};
Obviously this is a simple example, but when might I not want to use an anonymous inner class? Is it ever explicitly disallowed or impossible?
I'm seeing lots of answers to the first question, but none of the answers so far answer the second: Is it ever explicitly disallowed or impossible to use an anonymous inner class?