Search code examples
javahtmlcssgwtuibinder

GWT - how to change checkbox properties


I have a (an?) UiBinder which creates checkbox element this way:

<g:CheckBox ui:field="ignoreCase"/>     

in the java code, it uses this method to set the text

ignoreCase.setText(UIConverter.getUILocalization().get(UINames.IgnoreCase));

The result, in elements inspector is:

<span class="gwt-CheckBox FindEntDlgIgnoreCase">
    <input type="checkbox" value="on" id="gwt-uid-255" tabindex="0">
    <label for="gwt-uid-255">Ignore case<label>
</span>

I want to add the input element style property: margin-left:5px, but I don't find a way to get the input element.

How can I access it?


Solution

  • You can always do:

    ignoreCase.getElement().getChild(0)
    

    Another option is to create a CSS rule that you can apply consistently every time you need this margin. For example:

    .myBox input {
      margin-left: 5px;
    }
    

    You can set this class programmatically on your checkbox, or add it in UiBinder.