Reputation: 109
.class1{
font-weight: bold;
font-size:20px;
}
.class2{
background: #ffffff;
color: grey;
}
and GWT method
private static final String STYLE2 = class2;
private static final String STYLE1 = "class1";
HTML html = new HTML(htmlText);
String text = html.getText();
Label label = new Label();
if (text.length() <= 50) {
label.addStyleName(STYLE1);
} else {
text = text.substring(0, 500);
}
label.addStyleName(STYLE2);
label.setText(text);
}
what i want is when text become less than 50 apply both styles to label ... but it is overridden ... any help ??
Upvotes: 2
Views: 317
Reputation: 666
you can use setStyleName with class name and boolean parameter as below:
label.setStyleName(STYLE2,true);
here true is boolean value to add/append css class name.
An alternate solution can be to concatenate and apply those styles.
lable.addClassName(STYLE1 +" "+STYLE2);
Upvotes: 4