Ok, I checked two ways to do this. In both cases, you will leave the CheckBox label blank (no text in the label tag).
Option 1: You use <g:CheckBox> and <g:Label> (which creates the div), and you use this <g:Label> to simulate the Checkbox label.
In your ui.xml
<td> <g:Label ui:field="lbl">The Label</g:Label> </td> <td> <g:CheckBox ui:field="chk" /> </td>
In your java class:
@UiField Label lbl; @UiField CheckBox chk;
Option 2: You use HTML <label> instead of GWT <g:Label> and assign it the same identifier as the checkbox, so it becomes a hacky.
In your ui.xml
<td> <label ui:field="lbll">The Label</label> </td> <td> <g:CheckBox ui:field="chk" /> </td>
In your java class:
@UiField CheckBox chk; @UiField LabelElement lbll; @Override protected void onLoad() { super.onLoad();
EDIT: Think about it, option 1 is the best choice as it gives you ClickHandler and what you wanted. It is also less harmful.
source share