Gwt label background color

I need to implement the background in the shortcut, and also maybe just fill half of it with one color and the other with another. What is the best way to achieve this ?! Using CSS ?! Or there is another simpler way.

Thanks in advance

+3
source share
1 answer

This is what CSS is used for.

Label label = new Label("your text");
label.setStyleName("myStyle");

And in your .css file:

.myStyle {
  background-color: #f00;
}

Or if you use UIBinder:

<ui:style>
  .myStyle {
    background-color: #f00;
  }
</ui:style>
<g:HTMLPanel>
  <g:Label styleName="{style.myStyle}">Your text</g:Label>
</g:HTMLPanel>

The advantage of the UIBinder approach is that your style is in the same file as Label, and the CSS name will also be confused.

+5
source

Source: https://habr.com/ru/post/1792518/


All Articles