I have code like this:
TextBox txt = new TextBox(){
  public void onLoad(){
    this.addFocusHandler(new FocusHandler(){
      //some codes here
      //if I use "this" keyword, it refers to the handler, but how can I get a reference to the textbox?
    });
  }
};
Question is embedded in the position.
Edit:
In respect to the answers, the creation of a pre-defined reference works for this situation, but this apparently lost (or at least reduce) the benefits of anonymous object/function.
I hope to find a way without creating a new reference. Rather just to get the reference from that scope.
After all the answers, here is a conclusion:
- Reflection does not work in GWT. (at least I did not succeed) obj.getClass()works, but others likegetMethods()orgetEnclosingClass()don't work.
- The way to get a reference can either be declaring a reference in the right scope, or get a higher level object reference and reference downwards. I prefer the latter simply because you don't need to create a new variable.
 
     
     
     
     
     
    