Suggestion :
Try learning how to use UiBinder (added in GWT 2.0).
In your case, you could have done :
yourView.ui.xml
...
<g:Button ui:field="btnName" />
...
yourView.java
public class yourView extends Composite {
interface MyUiBinder extends UiBinder<LayoutPanel, yourView> {}
private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
@UiField Button btnName;
public yourView() {
initWidget(uiBinder.createAndBindUi(this));
}
@UiHandler("btnName")
void handleClick(ClickEvent e) {
//Do whatever
}
}
With "@UiHandler" you can add any handler the widget can support (implement Has****Handler). Adding other element to that structure is easy and FAST and you can add any kind of handler to it. @UiField create a variable containing the instance of the element that is manipulatable anywhere in your class.