This is what I'm doing now. Is there a better way to access the super class?
public class SearchWidget {
private void addWishlistButton() {
final SearchWidget thisWidget = this;
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// A better way to access the super class?
// something like "this.super" ...?
workWithWidget(thisWidget);
}
}
}
}
I'm programming with Google Web Toolkit, but I think this is really a generic Java question.
You can use what is called the qualified
this
.JLS 15.8.4. Qualified This
In this case, you can do what Martijn suggests, and use:
References
Related questions
You can write the name of the outer class and then
.this
. So:To access
super
of the object that contains an object of an anonymous class from that object, try, in your caseSearchWidget.super
Example:(see the third call
Child.super.print()
)